Codeforces Round #426 (Div. 2) C
来源:互联网 发布:excel函数重复数据 编辑:程序博客网 时间:2024/06/07 09:41
一道大水题.
考虑到输入的a,b,得到一个g=gcd(a,b),令x=a/g,y=b/g,x,y一定是互质的,而且x|g,y|g,令g/=(x*y)后一定是一个数的三次方,考虑到a, b<1e9,打个1000的表lower_bound一下就可以了
#include<cstdio>#include<iostream>#include<algorithm>const int N = 1111;using namespace std;int x3[N];int gcd(int a, int b){ return b?gcd(b,a%b):a;}void init(){ for(int i = 0; i < 1111; i++){ x3[i]=i*i*i; }}bool judge(int a){ int pos = lower_bound(x3,x3+1111,a)-x3; //cout << x3[pos]<<endl; if(x3[pos]!=a)return true; return false;}int main(){ init();int t,a,b;scanf("%d",&t); while(t--){ bool flag = 0; scanf("%d%d",&a,&b); int g = gcd(a,b); int x = a/g; int y = b/g; if(g%x!=0)flag=1; else{ g/=x; if(g%y!=0)flag=1; else { g/=y; if(judge(g)){ flag = 1; } } } if(flag)puts("No"); else puts("Yes"); } return 0;}
阅读全文
1 0
- Codeforces Round #426 (Div. 2) C
- Codeforces Round #426 (Div. 2) C
- Codeforces Round #426 (Div. 2) C
- 【codeforces】Codeforces Round #370 (Div. 2) C
- Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2) A B C
- (Codeforces Round #426 (Div. 2)) C.The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #426 (Div. 2)-C. The Meaningless Game
- Codeforces Round #426 (Div. 2) C The Meaningless Game
- Codeforces Round #426 (Div. 2) A B C
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #426 (Div. 2) A B C D E
- 3 如何修改文字颜色
- 《算法导论》第四章-第1节_练习(参考答案)
- Mahout 聚类算法学习之Canopy(一)
- Redis4.0.1 安装、设置密码、开启远程访问
- 深度理解链式前向星
- Codeforces Round #426 (Div. 2) C
- A. Knight Tournament----并查集
- OAuth的三种认证方式
- 外国商标中国注册的规定有哪些
- day18之用shell脚本实现一个希尔排序
- 编写一个函数,分别统计出传入字符串参数(可能不止一个参数)的英文字母,空格,数字和其他字符的个数
- 统计字符串—公约公倍数—计负均正
- 计算机的三大法则
- Meaven jar包服务器搭建(windows 系统)