(Codeforces Round #426 (Div. 2)) C.The Meaningless Game
2017-07-31 15:00
411 查看
题目
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
注意点
[b]scanf(“%lld%lld”,&x,&y);//cin,cout影响输入速度会t[/b][b]LL c =ceil( pow(a*1.0, 1.0/3)),d =ceil(pow(b*1.0, 1.0/3));//调整精度[/b]
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; }
相关文章推荐
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #426 (Div. 2) B.The Festive Evening+C.The Meaningless Game
- 【筛法求素数】Codeforces Round #426 (Div. 1) A. The Meaningless Game
- Codeforces Round #426 (Div. 2) B.The Festive Evening+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. 1) A. The Meaningless Game
- C. The Meaningless Game(Codeforces Round #426 (Div. 2) C)
- Codeforces Round #426 (Div. 2) C - The Meaningless Game
- Codeforces Round #426 (Div. 2) B.The Festive Evening+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)The Meaningless Game【数学题】【水题】
- 【Codeforces Round #426 (Div. 2) C】The Meaningless Game
- Codeforces Round #426 (Div. 2) B.The Festive Evening+C.The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game(gcd,数论)
- Codeforces Round #426 (Div. 2) B.The Festive Evening+C.The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2) C The Meaningless Game