HUST 1606 判断一个数是否是3个数的立方和 (暴力)

来源:互联网 发布:java入门教程视频教程 编辑:程序博客网 时间:2024/06/17 23:06


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)

Output

For each test case, print “Yes” if it is or “No” if it isn’t. 
(See sample for more details)

Sample Input

1310

Sample Output

NoYesYes


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;}






0 0
原创粉丝点击