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.

a×b能开立方根并且立方根同时整除a、b则可以,否则不可以。

 //2017-08-16
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long using namespace std; int main()
{
int n;
ll a, b, c;
while(scanf("%d", &n)!=EOF){
for(int i = ; i < n; i++){
scanf("%I64d%I64d", &a, &b);
c = ceil(pow(a*b, 1.0/));//ceil为向上取整函数
if(c*c*c == a*b && a%c== && b%c==)
printf("Yes\n");
else printf("No\n");
}
} return ;
}

Codeforces833A的更多相关文章

随机推荐

  1. Spring Boot多数据源配置与使用

    在单数据源的情况下,Spring Boot的配置非常简单,只需要在application.properties文件中配置连接参数即可.但是往往随着业务量发展,我们通常会进行数据库拆分或是引入其他数据库 ...

  2. 异步三部曲之promise

    概述 这是我看你不知道的JavaScript(中卷)的读书笔记,供以后开发时参考,相信对其他人也有用. 例子 首先来看一个例子,如果我们要异步获取x和y,然后把他们打印出来,那么用回调可以编写代码如下 ...

  3. solr初识

    参考资料http://blog.csdn.net/l1028386804/article/details/70199983

  4. vue.js生命周期钩子函数及缓存

    在使用vue.js进行开发时,使用最多的就是created.mounted.activated. 由于有些情况下,我们需要复用某些组件,因此需要用到keep-alive. 当引入keep-alive时 ...

  5. JPA-style positional param was not an integral ordinal

    参数错误 多为SQL语句问题 例如SQL拼装中的空格,换行时首位应多加空格保持语句效果

  6. java里面main函数为什么要用static修饰

    这学期刚开java,因为之前只写过C++和Python没接触过java,有些写法挺不习惯的,今天写完一个程序,run的时候发现提示the selection can't be launched.... ...

  7. CentOS 6(64-bit) + Nginx搭建静态文件服务器

    Nginx搭建静态文件服务器 使用命令打开Nginx配置文件: sudo vim /etc/nginx/conf.d/default.conf 将配置改为: server { ...... ..... ...

  8. PHP:WampServer下如何安装多个版本的PHP、mysql、apache

    作为Web开发人员,在机器上安装不同版本的php,apache和mysql有时是很有必要的. 今天,我在调试一套PHP程序的时候,该程序中使用的某些函数在低版本中无法使用,所以只能在搞个高版本的php ...

  9. DataSet 多表关系

    protected void Page_Load(object sender, EventArgs e) { string connectionString = @"Data Source= ...

  10. Iptables之recent模块小结

    Iptables的recent模块用于限制一段时间内的连接数, 是谨防大量请求攻击的必杀绝技! 善加利用该模块可充分保证服务器安全. recent常用参数--name      设定列表名称,即设置跟 ...