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 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.

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

#include<cstdio>
#include<cmath>
#define ll long long int main()
{
int n;
scanf("%d",&n);
while(n--)
{
ll a,b;//注意数值类型
scanf("%I64d%I64d",&a,&b);
ll ans = ceil(pow(a*b, 1.0/3));//向上取整
if(ans*ans*ans == a*b && a%ans == 0 && b%ans ==0)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}

真的好神奇!!!

A. The Meaningless Game(数学)的更多相关文章

  1. Codeforces 834C - The Meaningless Game

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

  2. Code Forces 833 A The Meaningless Game(思维,数学)

    Code Forces 833 A The Meaningless Game 题目大意 有两个人玩游戏,每轮给出一个自然数k,赢得人乘k^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数 ...

  3. Codeforces Round #426 (Div. 1) A.The Meaningless Game (二分+数学)

    题目链接: http://codeforces.com/problemset/problem/833/A 题意: 给你 \(a\) 和 \(b\),两个人初始化为 \(1\).两个人其中一方乘以 \( ...

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

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

  5. 数学思想:为何我们把 x²读作x平方

    要弄清楚这个问题,我们得先认识一个人.古希腊大数学家 欧多克索斯,其在整个古代仅次于阿基米德,是一位天文学家.医生.几何学家.立法家和地理学家. 为何我们把 x²读作x平方呢? 古希腊时代,越来越多的 ...

  6. 速算1/Sqrt(x)背后的数学原理

    概述 平方根倒数速算法,是用于快速计算1/Sqrt(x)的值的一种算法,在这里x需取符合IEEE 754标准格式的32位正浮点数.让我们先来看这段代码: float Q_rsqrt( float nu ...

  7. MarkDown+LaTex 数学内容编辑样例收集

    $\color{green}{MarkDown+LaTex 数学内容编辑样例收集}$ 1.大小标题的居中,大小,颜色 [例1] $\color{Blue}{一元二次方程根的分布}$ $\color{R ...

  8. 深度学习笔记——PCA原理与数学推倒详解

    PCA目的:这里举个例子,如果假设我有m个点,{x(1),...,x(m)},那么我要将它们存在我的内存中,或者要对着m个点进行一次机器学习,但是这m个点的维度太大了,如果要进行机器学习的话参数太多, ...

  9. Sql Server函数全解<二>数学函数

    阅读目录 1.绝对值函数ABS(x)和返回圆周率的函数PI() 2.平方根函数SQRT(x) 3.获取随机函数的函数RAND()和RAND(x) 4.四舍五入函数ROUND(x,y) 5.符号函数SI ...

随机推荐

  1. 【原】Coursera—Andrew Ng机器学习—Week 7 习题—支持向量机SVM

    [1] [2] Answer: B. 即 x1=3这条垂直线. [3] Answer: B 因为要尽可能小.对B,右侧红叉,有1/2 * 2  = 1 ≥ 1,左侧圆圈,有1/2 * -2  = -1 ...

  2. Python的索引迭代

    Python中,迭代永远是取出元素本身,而非元素的索引. 对于有序集合,元素确实是有索引的.有的时候,我们确实想在 for 循环中拿到索引,怎么办? 方法是使用 enumerate() 函数: > ...

  3. Ajax 简单实例,其实就是js里面内容有些不同而已(转载)

    这些时间,瞎子也看得见,AJAX正大踏步的朝我们走来.不管我们是拥护也好,反对也罢,还是视而不见,AJAX像一阵潮流,席转了我们所有的人. 关于AJAX的定义也好,大话也好,早有人在网上发表了汗牛充栋 ...

  4. 【BZOJ3926】诸神眷顾的幻想乡 【广义后缀自动机】

    题意 给定一棵树,每个结点有一个颜色,问树上有多少种子串(定义子串为两点上路径颜色的序列).保证叶子结点<=20 分析 我们可以发现一个结论,任意一个子串一定是以某个叶子结点为根的trie的后缀 ...

  5. 【poj1743】Musical Theme 【后缀自动机】

    题意 给出一个n个数字的序列,找出相同变化趋势且不重叠的两个最长子串. 分析 这个题以前应该用后缀数组+二分做过.学了后缀自动机后可以用后缀自动机搞一下. 先差分,然后把查分后的数组建SAM.然后对于 ...

  6. linux 安装网络监控插件indicator-sysmonitor

    1.添加源 sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor 2.更新源 sudo apt-get update 3.安装 su ...

  7. Ubuntu Server 12.04 LTS搭建SVN服务及修改端口

    采用了apache结合svn的方式. 首先安装apache.subversion.svn-apache sudo apt-get install apache2 sudo apt-get instal ...

  8. LINK : fatal error LNK1104: cannot open file "mfc42d.lib"

    VC++6.0上建立了个基于MFC应用程序,在编译时候没出现错误,但在LINK的是时候出现这样的错误:Linking...LINK : fatal error LNK1104: cannot open ...

  9. Openssl rsautl命令

    一.简介 rsautl指令能够使用RSA算法签名,验证身份,加密/解密数据 二.语法 openssl rsautl [-in file] [-out file] [-inkey file] [-pas ...

  10. dll详解

    [转]http://www.cnblogs.com/xuemaxiongfeng/articles/2461632.html 不解为什么要用WINAPI宏定义,查了后发现下面的定义.于是乎需要区别 _ ...