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).
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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
ll n;
scanf("%lld", &n);
if ((n - 1) % 3)
{
printf("NO\n");
continue;
}
ll x = (ll)sqrt((n - 1) / 3);
if (x * (x + 1) == (n - 1) / 3)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}

数学--数论--hdu 6216 A Cubic number and A Cubic Number (公式推导)的更多相关文章

  1. 数学--数论-- HDU -- 2854 Central Meridian Number (暴力打表)

    A Central Meridian (ACM) Number N is a positive integer satisfies that given two positive integers A ...

  2. 数学--数论--HDU - 6395 Let us define a sequence as below 分段矩阵快速幂

    Your job is simple, for each task, you should output Fn module 109+7. Input The first line has only ...

  3. 数学--数论--HDU 2582 F(N) 暴力打表找规律

    This time I need you to calculate the f(n) . (3<=n<=1000000) f(n)= Gcd(3)+Gcd(4)+-+Gcd(i)+-+Gc ...

  4. 数学--数论--HDU - 6322 打表找规律

    In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n ...

  5. 数学--数论--hdu 5878 I Count Two Three(二分)

    I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all started ...

  6. 数学--数论-- HDU 2601 An easy problem(约束和)

    Problem Description When Teddy was a child , he was always thinking about some simple math problems ...

  7. 数学--数论--HDU - 6124 Euler theorem (打表找规律)

    HazelFan is given two positive integers a,b, and he wants to calculate amodb. But now he forgets the ...

  8. 数学--数论--HDU 6063 RXD and math (跟莫比乌斯没有半毛钱关系的打表)

    RXD is a good mathematician. One day he wants to calculate: output the answer module 109+7. p1,p2,p3 ...

  9. 数学--数论--HDU 1299 +POJ 2917 Diophantus of Alexandria (因子个数函数+公式推导)

    Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...

随机推荐

  1. spring06

    主要是学会spring中关于通过注释来配置bean. 以及处理怎样智选其一或者补选某一个bean还有就是关于当出现多个相同的bean的时候怎样配置: 具体的代码和配置文件如下: <?xml ve ...

  2. 当const放在function声明后

    #include <iostream> class MyClass { private: int counter; public: void Foo() { std::cout <& ...

  3. Linux 磁盘管理篇,设备文件

    IDE硬盘                /dev/hd[a-d] SCSI/SATA/USB硬盘        /dev/sd[a-p] U盘                /dev/sd[a-p] ...

  4. Struts2-学习笔记系列(12)-set集合

    3.1编写类型转换器  只需实现 converFromString方法 public class UserConvert extends StrutsTypeConverter { @Override ...

  5. zookeeper的下载安装和选举机制(zookeeper一)

    1. 简要概述 Zookeeper是一个开源的分布式的,为分布式应用提供协调服务的框架.Zookeeper从设计模式角度来理解:是一个基于观察者模式设计的分布式服务管理框架它负责存储和管理大家都关心的 ...

  6. java的图形化界面 文本区JTextArea的程序例子

    package java1;     //使用时这个改成你的包名即可//文本区 JTextArea import javax.swing.*;import java.awt.*;import java ...

  7. AJ学IOS(05)UI之360等下载管理器九宫格UI

    AJ分享,必须精品 先看效果 主要是完成了九宫格UI的搭建 代码 - (void)viewDidLoad { [super viewDidLoad]; //九宫格中每个格子的宽 #define kAp ...

  8. Thinking in Java,Fourth Edition(Java 编程思想,第四版)学习笔记(十四)之Type Information

    Runtime type information (RTTI) allow you to discover and use type information while a program is ru ...

  9. 给想学python但还没有接触过的你,python代码的书写规则,小白入门

    Python 文件结构 变量命名 注释 单行注释 多行注释 缩进 Python 文件结构 #!/usr/bin/env python3 # 指定python解释器 # -*- coding: utf- ...

  10. stand up meeting 1-6

    今日更新: 1.修复初始最佳战绩显示bug:  初始为击败全国0% 用户 2.挑战结果界面显示“哎,今天的饭又白吃了,回去多吃两碗###”, 去除API返回string中的“###”. 3.分享模块初 ...