codeforces 833A
2017-08-02 15:05
363 查看
思路:看n *m是否是完全三次方的数
以前不知道pow开方怎么消除误差,直接ceil()或者加个0.5在floor一下。
以前不知道pow开方怎么消除误差,直接ceil()或者加个0.5在floor一下。
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; typedef set<int>::iterator ITER; #define fi first #define se second #define INF 0x3f3f3f3f #define clr(x,y) memset(x,y,sizeof x) const int maxn = 1e5 + 10; const int Mod = 1e9 + 7; const int N = 2; struct Matrix{Matrix(){clr(m,0);}int m ;}; Matrix Mul(Matrix a,Matrix b){Matrix c;for(int i = 0; i < N; i ++){for(int k = 0; k < N; k ++){if(a.m[i][k] == 0)continue;for(int j = 0; j < N; j ++)c.m[i][j] += a.m[i][k] * b.m[k][j] % Mod,c.m[i][j] %= Mod;}}return c;} ll Mul(ll a,ll b){a %= Mod;b %= Mod;ll ret = 0;while(b){if(b & 1){ret += a;if(ret > Mod)ret -= Mod;}b >>= 1;a = (a << 1) % Mod;}return ret;} Matrix pows(Matrix x,ll n){Matrix ret;for(int i = 0; i < 2; i ++)ret.m[i][i] = 1;while(n){if(n & 1)ret = Mul(ret,x);x = Mul(x,x);n >>= 1;}return ret;} ll pows(ll x,ll n){ll ret = 1;while(n){if(n & 1)ret = ret * x % Mod;x = x * x % Mod;n >>= 1;}return ret;} ll powss(ll x,ll n){ll ret = 1;while(n){if(n & 1)ret = Mul(ret,x);x = Mul(x,x);n >>= 1;}return ret;} ll gcd(ll x,ll y){return y ? gcd(y,x % y):x;} ll euler(int n){int ret = n;for(int i = 2; i * i<= n; i ++)if(n % i == 0){ret = ret / i * (i - 1);while(n % i == 0)n /= i;}if(n > 1)ret = ret / n * (n - 1);return ret;} void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d = a;x = 1;y = 0;return;}ex_gcd(b,a % b,d ,y,x);y -=a/b * x;} inline int lowbit(int x){return x &(-x);} //void update(int x,int val){for(int i = x; x < maxn; i += lowbit(i))tree[i] += val;} //void get(int x){int ret = 0;for(int i = x; i > 0 ;i -= lowbit(i))ret += tree[i];return ret;} //int finds(int x){return fa[x] == x ? x : (fa[x] = finds(fa[x]));} int main() { int Tcase; scanf("%d",&Tcase); ll n,m; while(Tcase --) { scanf("%I64d%I64d",&n,&m); ll t = ceil(pow(n * m,1.0/3)); if(t * t * t == n * m && n % t == 0 && m % t == 0) puts("Yes"); else puts("No"); } return 0; }
相关文章推荐
- Codeforces 833A-The Meaningless Game
- codeforces 669B B. Little Artem and Grasshopper(水题)
- Codeforces 723E One-Way Reform(欧拉回路)
- Codeforces 937D - Sleepy Game 【博弈+判环】
- codeforces 3B Lorry
- Codeforces 570D - Tree Requests【树形转线性,前缀和】
- [思路题] Codeforces 377A #222 (Div. 1) A. Maze
- CodeForces 359A Table
- CodeForces 558D
- codeforces 580D:Kefa and Dishes
- 3.22省赛训练赛(codeforces 33、34)
- CodeForces 339A Helpful Maths
- codeforces 343A Rational Resistance
- CodeForces 779B Weird Rounding
- Codeforces 842B. Gleb And Pizza 模拟
- CodeForces 669E Little Artem and Time Machine(树状数组)
- Codeforces 219D. Choosing Capital for Treeland (树dp)
- Codeforces 955C. Sad powers
- codeforces April Fools Day Contest 2014 A. The Great Game
- Codeforces 474 A