Advertisement
LEGEND2004

Sum of Cubes

Jul 13th, 2023
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6.  
  7. signed main()
  8. {
  9.     map<int , bool> cube;
  10.     for(int i = 1; i <= 10000; i++){
  11.         cube[i * i * i] = true;
  12.     }
  13.  
  14.     int t , n;
  15.     cin >> t;
  16.     while(t--){
  17.         cin >> n;
  18.         bool ok = false;
  19.         for(int i = 1; (i * i * i) < n; i++){
  20.             if(cube[n - (i * i * i)]){
  21.                 ok = true;
  22.                 break;
  23.             }
  24.         }
  25.         cout << (ok ? "yEs" : "nO") << endl;
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement