题目

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

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^2,谁乘以k,他们一定是都至少乘了一个k,并且他两个人的乘积一定是乘了一个k的三次方。

所以先把所有数字的三次方存一下,然后先判断这两个数字乘积是否为三次方的数字,若是的话,在判断这两个数字是否是这个数字的x的倍数。是的话为Yes,否则No。

代码

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define ll long long
const int maxn = 1e6+;
map<ll,int>jl;
int main(){
for(ll i = ;i <= ;++i){
jl[i*i*i]=i;
}
int n;
ll a,b;
scanf("%d",&n);
for(int i=;i<=n;++i){
scanf("%lld%lld",&a,&b);
int shu = jl[a*b];
if(shu && a%shu == && b%shu == )
printf("Yes\n");
else printf("No\n");
}
return ;
}

The meaningless Game的更多相关文章

  1. Cassandra - Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless

    In cassandra 2.1.4, if you run "nodetool status" without any keyspace specified, you will ...

  2. C. Meaningless Operations Codeforces Global Round 1 异或与运算,思维题

    C. Meaningless Operations time limit per test 1 second memory limit per test 256 megabytes input sta ...

  3. Codeforces 833A The Meaningless Game - 数论 - 牛顿迭代法 - 二分法

    Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting. T ...

  4. Codeforces Round #426 (Div. 2) C. The Meaningless Game

    C. The Meaningless Game 题意: 两个人刚刚开始游戏的时候的分数, 都是一分, 然后随机一个人的分数扩大k倍,另一个扩大k的平方倍, 问给你一组最后得分,问能不能通过游戏得到这样 ...

  5. Codeforces 834C - The Meaningless Game

    834C - The Meaningless Game 数学. 思路1:判断a•b能不能化成v3且a%v==0且b%v==0.v可以直接用pow求(或者用cbrt),也可以二分求:还可以用map映射预 ...

  6. A. The Meaningless Game(数学)

    A. The Meaningless Game time limit per test:1 second memory limit per test:256 megabytes input:stand ...

  7. Codeforces Round #426 The Meaningless Game

    题目网址:http://codeforces.com/contest/834/problem/C 题目: C. The Meaningless Game Slastyona and her loyal ...

  8. CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)

    /* CodeForces 834C - The Meaningless Game [ 分析,数学 ] | Codeforces Round #426 (Div. 2) 题意: 一对数字 a,b 能不 ...

  9. MDK中问题:warning : type qualifier is meaningless on cast type return 的解决

    在MDK编译代码时,有时会出现这样的警告, warning : type qualifier is meaningless on cast type return 在MDK中,作如下设置: 即添加 : ...

随机推荐

  1. 使用turtle库绘制一个六角形

    from turtle import * color("black","red") begin_fill() pu() fd(-200) pd() seth(3 ...

  2. windows FTP工具,Windows FTP工具下载!

    IIS7服务器管理工具能够作为FTP的客户端,进行FTP的命令操作,可在客户端,下载,安装FTP软件! 同时,它也可以作为VNC的客户端,进行VNC的命令操作!它能够批量连接Windows和Linux ...

  3. Java实现 LeetCode 636 函数的独占时间(栈)

    636. 函数的独占时间 给出一个非抢占单线程CPU的 n 个函数运行日志,找到函数的独占时间. 每个函数都有一个唯一的 Id,从 0 到 n-1,函数可能会递归调用或者被其他函数调用. 日志是具有以 ...

  4. Java实现 LeetCode 405 数字转换为十六进制数

    405. 数字转换为十六进制数 给定一个整数,编写一个算法将这个数转换为十六进制数.对于负整数,我们通常使用 补码运算 方法. 注意: 十六进制中所有字母(a-f)都必须是小写. 十六进制字符串中不能 ...

  5. Linux权限管理命令chown、chgrp、umask详解

    命令chown详解 命令chown,所在路径为: 可以看到,这个命令的路径为:/usr/bin/chown ,所以它的执行权限是所有用户 命令的基本功能是改变文件或目录的所有者(只有root可以进行, ...

  6. 【asp.net core】7 实战之 数据访问层定义

    0. 前言 在上一篇,我们搭建了一个项目框架,基本上是一个完整的项目.目前而言,大部分的应用基本都是这个结构.好的,不废话了,进入今天的议题:完成并实现数据层的基础实现. 1. 数据实体 通常情况下, ...

  7. 【优雅写代码系统】springboot+mybatis+pagehelper+mybatisplus+druid教你如何优雅写代码

    目录 spring基本搭建 整合mybatis pom配置 mybatis配置 设置数据源 设置sqlsessionfactory 设置扫描 设置开启事务 资源放行 测试 结果 思考&& ...

  8. Java 切割字符串的几种方式

    按效率排: 1.StringTokenizer切割 是java.util中的一个类,包含的api有: StringTokenizer的方法请参考上一篇. 其中,countTokens为length:n ...

  9. JS 姓氏,区域,消息组成的随机内容定时随机展示

    var surname_g = "\u8D75\u94B1\u5B59\u674E\u5468\u5434\u90D1\u738B\u51AF\u9648\u891A\u536B\u848B ...

  10. RocketMQ系列(六)批量发送与过滤

    今天我们再来看看RocketMQ的另外两个小功能,消息的批量发送和过滤.这两个小功能提升了我们使用RocketMQ的效率. 批量发送 以前我们发送消息的时候,都是一个一个的发送,这样效率比较低下.能不 ...