Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main () {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- vector<long long> a;
- for (long long i = 1; i <= 10000; ++i) {
- long long p = pow(i,3);
- a.push_back(p);
- }
- int T;
- cin >> T;
- for (int test_case = 1; test_case <= T; ++test_case) {
- long long n;
- cin >> n;
- bool f = false;
- for (int i = 0; i < 10000; ++i) {
- long long x = a[i];
- long long y = n - x;
- int l = 0,r = 10000 - 1;
- //binary_search(a.begin(),a.end(),x); => true,false
- //~ if (binary_search(a.begin(),a.end(),y)) {
- //~ f = true;
- //~ break;
- //~ }
- while (l <= r) {
- int m = (l + r) / 2;
- if (a[m] == y) {
- f = true;
- break;
- } else if (a[m] > y) r = m - 1;
- else l = m + 1;
- }
- }
- if (f) {
- cout << "YES\n";
- } else {
- cout << "NO\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement