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. 解决 Android Studio 报SDK tools directory is missing

    问题描述: 因为之前已经有安装过sdk manager,在设置中将Android SDK Location设置为Android SDK安装的目录之后还是一直报SDK tools directory i ...

  2. Linux常用命令----基本文件系统常用命令

    1.查看当前工作目录---pwd sunny@sunny-ThinkPad-T450:~$ pwd /home/sunny sunny@sunny-ThinkPad-T450:~$ cd Worksp ...

  3. 设置Windows开机自动启动VirtualBox虚拟机系统

    如果常用VirtualBox虚拟机系统的话,设置随开机启动也是很方便的.不需要打开VirtualBox窗口,直接启动VirtualBox虚拟机系统就可以了. 设置开机自启动VirtualBox虚拟机系 ...

  4. Linux运维基础入门(三):网络基础知识梳理03

    一,ARP协议 使用ARP协议可以查出擅自更改IP地址主机的MAC地址.在学习ARP协议前需要了解广播和广播域的相关概念. 1.1 广播与广播域 在超市找人时,如果不知道对方的位置就需要到服务台通过广 ...

  5. css实现文本过长时自动添加省略号

    1. 效果 2. Html <div id="main_app_content" class="container"> <div class= ...

  6. 【BZOJ1013】球形空间产生器sphere

    高斯消元模板题 #include <cstdio> #include <cstring> #include <algorithm> #include <ios ...

  7. 111. Minimum Depth of Binary Tree (Tree; DFS)

    Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...

  8. &&与||的短路运算

    在谈&&和||两个运算符的短路运算之前,先看一段程序: #include <stdio.h> int main() { , para2 = , para3 = , para ...

  9. 钉钉开发笔记(5)android系统中html软键盘的适配

    最近项目中发现个别Android手机中存在弹出的软键盘会遮挡输入框的现象,最后自己写了一个方法(如下),问题基本解决. 记录下来,防止忘记.有什么不对的地方欢迎指正.O(∩_∩)O 1 //键盘适配 ...

  10. SqlServer垂直分表 如何减少程序改动

    当单表数据太多时,我们可以水平划分,参考 SqlServer 分区视图实现水平分表 ,水平划分可以提高表的一些性能. 而 垂直分表 则相对很少见到和用到,因为这可能是数据库设计上的问题了.如果数据库中 ...