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. ubuntu上安装redis和配置远程访问

    ubuntu上安装redis和配置远程访问 安装redis: 下载安装包: wget http://download.redis.io/releases/redis-4.0.1.tar.gz 解压: ...

  2. websocket聊天室

    目录 websocket方法总结 群聊功能 基于websocket聊天室(版本一) websocket方法总结 # 后端 3个 class ChatConsumer(WebsocketConsumer ...

  3. 计算机网络协议,IPV4数据报分析

    一.IP数据报结构分析 1.整体结构 一个IP数据报由首部和数据两部分组成. 首部的前一部分固定长20字节,这是所有IP数据报必须具有的:在首部的固定部分后面是一些可选字段,其长度是可变的. IP数据 ...

  4. javascript 入门(1)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta lang ...

  5. javascript入门 之 Ajax(一)

    1.在项目的根目录下创建data目录,data目录下创建info文件,编写info文件如下代码: <h1>all data<h2> <p>this is the d ...

  6. coding++:jdk1.7 HashMap 的get()和put() 源码

    HashMap的概述:    基于哈希表的 Map 接口的实现.    此实现提供所有可选的映射操作,并允许使用 null 值和 null 键. (除了非同步和允许使用 null 之外,HashMap ...

  7. SVG案例:动态去创建元素createElementNS

    案例一: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <titl ...

  8. phoenix 索引实践

    准备工作 创建测试表 CREATE TABLE my_table ( rowkey VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR, v3 V ...

  9. 谈谈MySQL的索引

    目录 索引 前言 是什么 B树 B+树 B树和B+树结构上异同 有什么用 怎么用 索引 前言 总所周知,数据库查询是数据库的最主要功能之一.我们都希望查询数据的速度能尽可能的快.而支撑这一快速的背后就 ...

  10. web测试流程

    1.立项后测试需要拿到文档(需求说明书,原型图,接口文档,) 2.需求评审 3.用例编写(主流程,备流程,异常流,业务规则,正常类,异常类,页面检查) 测试用例编写方法(等价类划分,边界值分析法,错误 ...