A Cubic number and A Cubic Number

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)

Total Submission(s): 4947    Accepted Submission(s): 1346


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

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

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

Sample Output
  1.  
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
 

Source
  1.  
输入输出测试
 

Statistic | Submit | Clarifications | Back

  1. #include <math.h>
  2. #include<iostream>
  3. #include<vector>
  4. #define ll long long int
  5. using namespace std;
  6. vector<ll> t_vec;
  7. bool fun(ll a) {
  8. a = (a - 1);
  9. if (a % 3 != 0) {
  10. return false;
  11. }
  12. a = a / 3;
  13. ll tem = sqrt(a);
  14. if (tem*(tem + 1) == a)
  15. return true;
  16. else
  17. return false;
  18. }
  19. int main() {
  20. int t;
  21. ll n;
  22. cin >> t;
  23. while (t--) {
  24. cin >> n;
  25. if (fun(n))
  26. cout << "YES\n";
  27. else
  28. cout << "NO\n";
  29. }
  30. return 0;
  31. }

2017青岛网络赛1011 A Cubic number and A Cubic Number的更多相关文章

  1. HDU 6212 Zuma 2017青岛网络赛 区间DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6212 解法:看了眼题就发现这个BZOJ 1032不是一毛一样?但是BZOJ上那是个巨坑,数据有错,原来 ...

  2. 2017青岛网络赛1008 Chinese Zodiac

    Chinese Zodiac Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) T ...

  3. 2017 青岛网络赛 Chenchen, Tangtang and ZengZeng

    Chenchen, Tangtang and ZengZeng are starting a game of tic-tac-toe, played on a 3 × 3 board. Initial ...

  4. HDU 4758 Walk Through Squares (2013南京网络赛1011题,AC自动机+DP)

    Walk Through Squares Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Oth ...

  5. hdu5017:补题系列之西安网络赛1011

    补题系列之西安网络赛1011 题目大意:给定一个椭球: 求它到原点的最短距离. 思路: 对于一个椭球的标准方程 x^2/a^2 + y^2/b^2 +z^2/c^2=1 来说,它到原点的最短距离即为m ...

  6. HDU 5880 Family View (2016 青岛网络赛 C题,AC自动机)

    题目链接  2016 青岛网络赛  Problem C 题意  给出一些敏感词,和一篇文章.现在要屏蔽这篇文章中所有出现过的敏感词,屏蔽掉的用$'*'$表示. 建立$AC$自动机,查询的时候沿着$fa ...

  7. 2017乌鲁木齐网络赛 j 题

    题目连接 : https://nanti.jisuanke.com/t/A1256 Life is a journey, and the road we travel has twists and t ...

  8. hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)

    题目链接 裸的结论题.百度 Ramsey定理.刚学过之后以为在哪也不会用到23333333333,没想到今天网络赛居然出了.顺利在题面更改前A掉~~~(我觉得要不是我开机慢+编译慢+中间暂时死机,我还 ...

  9. 2017 ICPC网络赛(西安)--- Xor

    题目连接 Problem There is a tree with n nodes. For each node, there is an integer value ai, (1≤ai​≤1,000 ...

随机推荐

  1. 莫比乌斯反演套路二--(n/d)(m/d)给提出来--BZOJ3529: [Sdoi2014]数表

    一个数表上第i行第j列表示能同时整除i和j的自然数,Q<=2e4个询问,每次问表上1<=x<=n,1<=y<=m区域内所有<=a的数之和.n,m<=1e5,a ...

  2. ZOJ - 3829 Known Notation(模拟+贪心)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 给定一个字符串(只包含数字和星号)可以在字符串的任意位置添加一个数字 ...

  3. PostgreSQL及PostGIS使用

    基础知识 参考文档:http://www.postgis.net/docs/ PostGIS支持的GIS对象是OpenGIS Consortium(OGC)定义的“简单特征”的超集.OpenGIS规范 ...

  4. cogs——1215. [Tyvj Aug11] 冗余电网

    1215. [Tyvj Aug11] 冗余电网 ★   输入文件:ugrid.in   输出文件:ugrid.out   简单对比 时间限制:1 s   内存限制:128 MB TYVJ八月月赛提高组 ...

  5. Java :面向对象

    Java :面向对象 直面Java 第001期 什么是面向过程 面向过程是以函数为中心,要解决一个问题,需要把问题分解为一个个的步骤,然后定义一系列的流程,用特定的输入经过函数的处理,最终输出特定的结 ...

  6. git的配置文件

    转载:https://cnbin.github.io/blog/2015/06/19/git-config-ming-ling-cha-kan-pei-zhi-wen-jian/ Git Config ...

  7. 网络最大流增广路模板(EK &amp; Dinic)

    EK算法: int fir[maxn]; int u[maxm],v[maxm],cap[maxm],flow[maxm],nex[maxm]; int e_max; int p[maxn],q[ma ...

  8. 比真机还快的Android模拟器——Genymotion

    比真机还快的Android模拟器--Genymotion                                                     ----转载请注明出处:coder-p ...

  9. PHP导入和导出CSV文件

    CREATE TABLE `student` ( `id` ) NOT NULL auto_increment, `name` varchar() NOT NULL, `sex` varchar() ...

  10. checkstyle+ant生成checkstyle报告

    <?xml version="1.0" encoding="UTF-8" ?> <project name="tibim" ...