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 (1≤T≤100)
which is the total number of test cases.
For each test case, a line contains a prime number p (2≤p≤1012) .
For each test case, a line contains a prime number p (2≤p≤1012) .
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;
}