(Codeforces Round #426 (Div. 2)) C.The Meaningless Game
来源:互联网 发布:裴乐品牌知乎 编辑:程序博客网 时间:2024/06/07 17:44
题目
http://codeforces.com/contest/834/problem/C
题解
先用GCD求出x,y的最小公倍数z
再求得p=x/z,q=y/z;
若x%p*p == 0 && y%q*q==0且z/p*q可开1/3次方为整数,则为Yes,否则为No
注意点
scanf(“%lld%lld”,&x,&y);//cin,cout影响输入速度会t
LL c =ceil( pow(a*1.0, 1.0/3)),d =ceil(pow(b*1.0, 1.0/3));//调整精度
AC代码
#include <bits/stdc++.h>#define INF 0x3f3f3f3f#define maxn 50000 + 10#define For(a,b) for(int i = a; i < b; i++)typedef long long LL;using namespace std;int a[maxn];LL gcd(LL a,LL b){ if(a%b == 0) return b; else return gcd(b,a%b);}int main(){ int n; scanf("%d",&n); while(n--) { LL x,y,z; LL p,q; scanf("%I64d%I64d",&x,&y); z = gcd(x,y); p = x/z; q = y/z; if(x % (p*p) == 0 && y % (q*q) == 0) { LL a = x/(p*p*q),b = y/(q*q*p); LL c =ceil( pow(a*1.0, 1.0/3)),d =ceil(pow(b*1.0, 1.0/3)); if(c*c*c == a && d*d*d == b) printf("Yes\n"); else printf("No\n"); } else printf("No\n"); } return 0; }
阅读全文
0 0
- Codeforces Round #426 (Div. 2) C. The Meaningless Game 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) 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) C:The Meaningless Game The Meaningless Game
- Codeforces Round #426 (Div. 2)The Meaningless Game(思维+二分)
- Codeforces Round #426 (Div. 2)The Meaningless Game(思维+二分)
- Codeforces Round #426 (Div. 2)The Meaningless Game【数学题】【水题】
- Codeforces Round #426 (Div. 2)The Meaningless Game(思维+二分)
- Codeforces Round #426 (Div. 2) C. The Meaningless Game 思维 D. The Bakery dp
- Codeforces Round #426 (Div. 2) B.The Festive Evening+C.The Meaningless Game
- C. The Meaningless Game(Codeforces Round #426 (Div. 2) C)
- Codeforces Round #426 (Div. 2) C. The Meaningless Game & A, B题代码及错误总结
- Codeforces Round #426 (Div. 2) A B C The Meaningless Game
- java使用SAX解析XML
- HDFS
- Codeforces Round #426 (Div. 2)The Meaningless Game(思维+二分)
- C. Vasya and Beautiful Arrays----思维题
- [PAT乙级]1022. D进制的A+B (20)
- (Codeforces Round #426 (Div. 2)) C.The Meaningless Game
- Codeforces Round #426 (Div. 2) B. The Festive Evening(思维)
- java操作Redis(哨兵或单机模式)
- Linux下Nginx的安装
- 在MVC 中使用 autofac 实现自动注册
- Luogu P2196 [NOIP1996]挖地雷
- 在Windows安装zip格式的mysql
- Firemonkey Session end错误
- java操作redis集群(基本操作)