概述
链接:https://codeforces.com/contest/833/problem/A?csrf_token=862e52f95602b95868e7c73a958718d7
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.
The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.
Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.
Input
In the first string, the number of games n (1 ≤ n ≤ 350000) is given.
Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.
Output
For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise.
You can output each letter in arbitrary case (upper or lower).
Example
input
Copy
6
2 4
75 45
8 8
16 16
247 994
1000000000 1000000
output
Copy
Yes
Yes
Yes
No
No
Yes
Note
First game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.
The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
代码:
#include<bits/stdc++.h>
using namespace std;
long long n,t,a,b,c,l,j,r,k,d,ans,max1=0,mod=1e9+7;
map<long long,long long>m;
int main()
{
cin>>t;
while(t--)
{
scanf("%lld %lld",&a,&b);
k=ceil(pow(a*b,1.0/3));
if(k*k*k==a*b&&a%k==0&&b%k==0)
printf("Yesn");
else
printf("Non");
}
}
最后
以上就是飘逸翅膀为你收集整理的A. The Meaningless Game的全部内容,希望文章能够帮你解决A. The Meaningless Game所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复