A. The Meaningless Game
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 ab (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
6
2 4
75 45
8 8
16 16
247 994
1000000000 1000000
output
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.

这一题看得出技巧的会觉得很简单,但像我这样看不出技巧的就。。。。

如题意:喊的快的乘k的平方,喊得慢的乘k;

所以a*b就是k的三次方的倍数。

即只需判断a*b是否三次方数,开三次方后,是不是a和b的因子即可。

代码如下:

#include <cstdio>
#include <cmath>
int main(){
long long n;
long long a,b;
scanf("%lld",&n);
while(n--){
scanf("%lld %lld",&a,&b);
long long u=floor(pow(a*b,1.0/3.0)+0.5);
if(u*u*u==a*b&&!(a%u)&&!(b%u)) puts("Yes");
else puts("No");
}
return 0;
}

最新文章

  1. android 项目中如何引入第三方jar包
  2. 【leetcode】Evaluate Reverse Polish Notation
  3. lvs+keeplived笔录
  4. assert函数
  5. ABBYY如何把图片转换成pdf格式
  6. An Oblivious Watermarking for 3-D Polygonal Meshes Using Distribution of Vertex Norms
  7. [改善Java代码]枚举项的数量限制在64个以内
  8. 北大ACM(POJ1004-Financial Management)
  9. wpf 绑定失效的原因及解决方案
  10. ASP.NET-FineUI开发实践-5
  11. php分页原理教程及简单实例
  12. java -ui自动化初体验
  13. ubuntu16下用QT5实现对话框应用
  14. 求FIRST集和FOLLOW集
  15. 【重要通知】本人所有技术文章转移至https://zzqcn.github.io
  16. C++:派生类的构造函数和析构函数的调用顺序
  17. CSDN博客栏目设置个性化
  18. 倒计时相关函数 php
  19. Linux 移动或重命名文件/目录-mv 的10个实用例子
  20. python-反射、新式类与经典类搜索的优先级

热门文章

  1. 09--Docker 安装tomcat9
  2. HTTPS请求HTTP接口被浏览器阻塞,python实现websocket客户端,websocket服务器,跨域问题,dwebsocket,https,拦截,服务端
  3. QTextEdit的paste
  4. QTextEdit字符串的高亮显示问题
  5. 浅谈java中线程和操作系统线程
  6. MySQL主从配置This operation cannot be performed with a running slave io thread; run STOP SLAVE IO_THREAD FOR CHANNEL &#39;&#39; first.
  7. innodb和myisam原理
  8. v-show和v-if指令的共同点和不同点?
  9. Phoenix的shell操作
  10. Spark高级数据分析——纽约出租车轨迹的空间和时间数据分析