您的位置:首页 > 其它

codeforces 833A

2017-08-02 15:05 363 查看
思路:看n *m是否是完全三次方的数

以前不知道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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: