Code Forces 833 A The Meaningless Game
Subject
There are two people playing the game, each round gives a natural number k, the winning person multiplies k ^ 2, the losing person multiplies k, gives the score of the last two people, asks whether two people can reach this score
I have to spit out a long English title. Only one sentence is translated ...
solution
It ’s also good to think that the
product is cubed to determine whether it is a factor of two numbers.
If it is, it is obviously not true,
otherwise it will be Yes.
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define int long long
using namespace std;
inline int read(){
int x = 0, w = 1;
char ch = getchar();
for(; ch > '9' || ch < '0'; ch = getchar()) if(ch == '-') w = -1;
for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
return x * w;
}
signed main(){
int n = read();
while(n--){
int a = read(), b = read();
int tmp = a * b;
// int awsl = pow(tmp, (1.0 / 3)) + 0.5;
int awsl = cbrt((double)a*(double)b);//在网上找到了这个开三次方的函数,啧啧
if(awsl * awsl * awsl != tmp || a % awsl || b % awsl) cout << "No" << endl;
else cout << "Yes" << endl;
}
return 0;
}