Description
Give you a positive integer x, determine whether it is the sum of three positive cubic numbers.
Input
There’re several test cases. For each case:
Only one line containing an integer x ( 1≤x≤10^6)
Only one line containing an integer x ( 1≤x≤10^6)
Output
For each test case, print “Yes” if it is or “No” if it isn’t.
(See sample for more details)
(See sample for more details)
Sample Input
1 3 10
Sample Output
No Yes Yes
a*a*a+b*b*b+c*c*c = Y
预处理一下就好了
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
const int N = 9000000 + 100;
int f[N];
int main()
{
int i,j,a,b,c,n;
for(a=1;a<=100;a++) {
for(b=1;b<=100;b++) {
for(c=1;c<=100;c++)
f[a*a*a+b*b*b+c*c*c]=1;
}
}
while(scanf("%d",&n)!=EOF) {
if(f[n]) printf("Yes\n");
else printf("No\n");
}
return 0;
}