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

10
2
3
5
7
11
13
17
19
23
29
 

Sample Output

NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
 

Source

输入输出测试
 

Statistic | Submit | Clarifications | Back

#include <math.h>
#include<iostream>
#include<vector>
#define ll long long int using namespace std;
vector<ll> t_vec;
bool fun(ll a) {
a = (a - 1);
if (a % 3 != 0) {
return false;
}
a = a / 3;
ll tem = sqrt(a);
if (tem*(tem + 1) == a)
return true;
else
return false;
}
int main() {
int t;
ll n;
cin >> t;
while (t--) {
cin >> n;
if (fun(n))
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}

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. [NOIP2004] 提高组 洛谷P1091 合唱队形

    题目描述 N位同学站成一排,音乐老师要请其中的(N-K)位同学出列,使得剩下的K位同学排成合唱队形. 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1,2…,K,他们的身高分别为T1,T2, ...

  2. memcache适用和不适用场景[转载]

    适用memcached的业务场景:1)如果网站包含了访问量很大的动态网页,因而数据库的负载将会很高.由于大部分数据库请求都是读操作,那么memcached可以显著地减小数据库负载.2)如果数据库服务器 ...

  3. UVA 11400_ Lighting System Design

    题意: 给定一系列灯泡的额定功率,电源价钱,一个灯泡的价格以及系统所需该种灯泡的数量.已知流过灯泡的电流相等,所以为省钱可以将电压小的灯泡换成电压大的灯泡,但是不能换成电压更小的灯泡,问最少要花多少钱 ...

  4. ESG操作指南

    ESG使用指南:1.ESG操作文档网站:ESG有个网站,是专门的操作文档网站,因为ESG三个环境,流程各不一样.地址:http://10.20.12.90:20567/esg-help-doc/2.E ...

  5. NYOJ 题目42 一笔画问题(欧拉图)

    一笔画问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:4 描写叙述 zyc从小就比較喜欢玩一些小游戏.当中就包含画一笔画.他想请你帮他写一个程序.推断一个图是否可以用一笔画下 ...

  6. 搭建wamp php环境

    点击下载wamp,wamp是一个集成环境,在安装过程中,我们要选择默认的浏览器以及默认的文本编辑器,安装步骤如下: 第一步,选择默认的浏览器(填写默认的浏览器可执行路径就行) 第二步,选择默认的文本编 ...

  7. 【剑指Offer学习】【面试题65:滑动窗体的最大值】

    题目:给定一个数组和滑动窗体的大小,请找出全部滑动窗体里的最大值. 举例说明 比如,假设输入数组{2,3,4,2,6,2,5,1}及滑动窗体的大小.那么一共存在6个滑动窗体,它们的最大值分别为{4,4 ...

  8. ajax请求锁屏功能

    我们有时候在进行ajax请求的时候希望页面不允许点击,等请求结束之后才可以进行点击,那么可以写: $(".cloudos-container").ajaxStart($.block ...

  9. redis 主从 及集群

    一.redis 主从架构 搭建redis 主从   (可以用一台主机,也可以两台主机) 环境准备: 一台服务器:192.168.206.6 操作系统:CentOS7.5 redis 版本: redis ...

  10. JsonArray和JsonObject的使用

    import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class JsonTest { public static v ...