Advertisement
7oSkaaa

Sum of Cubes

Aug 10th, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1.   #include <bits/stdc++.h>
  2.   using namespace std;
  3.  
  4.   #define cin(vec) for(auto& i : vec) cin >> i
  5.   #define cin_2d(vec, n, m) for(int i = 0; i < n; i++) for(int j = 0; j < m && cin >> vec[i][j]; j++);
  6.   #define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n";
  7.   #define cout_2d(vec, n, m) for(int i = 0; i < n; i++, cout << "\n") for(int j = 0; j < m && cout << vec[i][j] << " "; j++);
  8.   #define cout_map(mp) for(auto& [f, s] : mp) cout << f << "  " << s << "\n";
  9.   #define loop(a, b, c) for(int i = a ; i < (b); i += c)
  10.   #define fixed(n) cout << fixed << setprecision(n);
  11.   #define Ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  12.   #define fill(vec, value) memset(vec, value, sizeof(vec));
  13.   #define all(vec) vec.begin(),vec.end()
  14.   #define rall(vec) vec.rbegin(),vec.rend()
  15.   #define sz(x) int(x.size())
  16.   #define fi first
  17.   #define se second
  18.   #define Pair pair < int, int >
  19.   #define ll long long
  20.   #define ull unsigned long long
  21.   #define Mod  1'000'000'007
  22.   #define INF 2'000'000'000
  23.   #define PI acos(-1)
  24.  
  25.   void Code_Crush(){
  26.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  27.     #ifndef ONLINE_JUDGE
  28.       freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  29.     #endif
  30.   }
  31.  
  32.   int main(){
  33.       Code_Crush();
  34.       int t;                          cin >> t;
  35.       vector < ll > cubes;
  36.       for(ll i = 1; i <= 1e4; i++) cubes.push_back(i * i * i);
  37.       while(t--){
  38.         ll x;                         cin >> x;
  39.         bool exist = false;
  40.         for(ll i = 1; i <= 1e4; i++){
  41.           if(binary_search(all(cubes), x - (i * i * i))){
  42.             exist = true;
  43.             break;
  44.           }
  45.         }
  46.         cout << (exist ? "YES\n" : "NO\n");
  47.       }
  48.       return 0;
  49.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement