2017 icpc 青岛赛区 1011.A Cubic number and A Cubic Number

Problem Description
A cubic number is the result of using a whole number in a multiplication three times. For example,  3×3×3=27  so  27  is a cubic number. The first few cubic numbers are  1,8,27,64  and  125 . Given an prime number  p . Check that if  p  is a difference of two cubic numbers.
 

Input
The first of input contains an integer  T (1T100)  which is the total number of test cases.
For each test case, a line contains a prime number  p (2p1012) .
 

Output
For each test case, output 'YES' if given  p  is a difference of two cubic numbers, or 'NO' if not.
 

Sample Input
  
  
10 2 3 5 7 11 13 17 19 23 29
 

Sample Output
  
  
NO NO NO YES NO NO NO YES NO NO
 

Source
  
  
输入输出测试

水题;

【AC代码】

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

#define pi acos(-1.0)
#define eps 1e-10
#define pf printf
#define sf scanf
#define lson rt<<1,l,m
#define rson rt<<1|1,m+1,r
#define e tree[rt]
#define _s second
#define _f first
#define all(x) (x).begin,(x).end
#define mem(i,a) memset(i,a,sizeof i)
#define for0(i,a) for(int (i)=0;(i)<(a);(i)++)
#define for1(i,a) for(int (i)=1;(i)<=(a);(i)++)
#define mi ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define sq(x) (3*(x)*(x)-3*(i)+1)

const int inf=0x3f3f3f3f;
int t;
ll n,q[1000000];

void dabiao()
{
    ll i;
    for(i=2;i<=577352;i++)
    {
        q[i]=sq(i);
    }
}

int main()
{
    dabiao();
    sf("%d",&t);
    while(t--)
    {
        int tag=0;
        sf("%lld",&n);
        for(int i=2;i<=577352;i++)
            if(n==q[i])
            {
                puts("YES");
                tag=1;
                break;
            }
        if(!tag)
            puts("NO");
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值