hust 1606,乱搞

G - Naive
Time Limit:3000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu

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

1
3
10

Sample Output

No
Yes
Yes
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<cstdlib>
#include<algorithm>

using namespace std;

#define LL long long
#define ULL unsigned long long
#define UINT unsigned int
#define MAX_INT 0x7fffffff
#define MAX_LL 0x7fffffffffffffff
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))

#define N 1111111
#define M 1000000
int a[N];
int p[N];

int main(){
//  fstream fin("C:\\Users\\Administrator\\Desktop\\in.txt",ios::in);

//    memset(a,0,sizeof(a));
    int i,j=0;
    int b;
    for(i=1; i<=100; i++){
        a[j++]=i*i*i;
    }
    memset(p,0,sizeof(p));
    for(i=0; i<j; i++)
        for(int k=0; k<j; k++)
            for(int q=0; q<j; q++){
                int ss=a[i] + a[k] +a[q];
                if(ss <= M) p[ss]=1;
            }

    int x;
    while(scanf(" %d",&x)==1){
        printf("%s\n",(p[x] ? "Yes" : "No"));
    }
//  fin.close();
    return 0;
}

 

posted @ 2013-11-07 18:42  Ramanujan  阅读(198)  评论(0编辑  收藏  举报