hdu 6216 A Cubic number and A Cubic Number
来源:互联网 发布:信仰的定义知乎 编辑:程序博客网 时间:2024/06/05 11:49
http://acm.hdu.edu.cn/showproblem.php?pid=6216
判断一个数是不是2个立方数的差,由立方差公式可以得到这种数只可能是2个相邻立方数的差
所以先打表再二分找一遍即可
#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;long long int dp[611111];int main(){ long long int i; for(i=2;i<=600000;++i) { dp[i-1]=i*i*i-(i-1)*(i-1)*(i-1); } int T; cin>>T; while(T--) { long long int n; cin>>n; if(binary_search(dp+1,dp+600000,n)) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0;}
阅读全文
0 0
- hdu 6216 A Cubic number and A Cubic Number
- HDU 6216 A Cubic number and A Cubic Number
- HDU 6216 A Cubic number and A Cubic Number
- HDU 6216 A Cubic number and A Cubic Number
- HDU 6216 A Cubic number and A Cubic Number
- hdu 6216 A Cubic number and A Cubic Number
- hdu 6216 A Cubic number and A Cubic Number
- hdu 6216-A Cubic number and A Cubic Number
- HDU-6216 A Cubic number and A Cubic Number
- hdu 6216 A Cubic number and A Cubic Number
- HDU 6216 A Cubic number and A Cubic Number
- hdu 6216 A Cubic number and A Cubic Number
- A Cubic number and A Cubic Number
- A Cubic number and A Cubic Number
- **A Cubic number and A Cubic Number**
- A Cubic number and A Cubic Number
- A Cubic number and A Cubic Number
- A Cubic number and A Cubic Number
- 解决eclipse编译时报内存不足问题
- Map和List使用区别
- Quartz(二) quartz测试
- 光环国际PMP:看完你就知道什么是瞎忙与高效
- dagger2学习
- hdu 6216 A Cubic number and A Cubic Number
- Java并发编程:volatile关键字解析
- StratoIO WebPrinter 是什么?StratoIO WebPrinter实现打印的过程,StratoIO WebPrinter Javascript API
- CDH 安装spark后,spark-shell启动报错
- Iterator遍历器删除集合中元素抛异常
- 使用Anaconda与pip报错'_NamespacePath' object has no attribute 'sort'的解决方法
- 计蒜客 16957 Skiing(2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 H)
- SparkStream:4)foreachRDD详解
- Hive 连接查询JOIN