Codeforces833A
A. The Meaningless Game
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则可以,否则不可以。
//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的更多相关文章
随机推荐
- Linux系统Bash的常用功能(9)
了解了基本的Linux文件文件系统的概念后,我们将更深入的了解一下Linux的其他方面的内容,那就是我们所使用的用户接口,也就是大家常听到的 『Shell』 ,『这个shell并不是黑客反弹的shel ...
- MariaDB 连接查询与子查询(6)
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可MariaDB的目的是完全兼容MySQL,包括API和命令行,MySQL由于现在闭源了,而能轻松成为MySQ ...
- PHP正则表达式函数的替代函数
1,preg_split()函数将字符串按照某元素分割,分割后结果以数组方式返回. php中explode()可以实现此功能.array explode(string $pattern,string ...
- opencv2.4.13.7的resize函数使用(c++)
先来看一下resize函数的原型,如下. C++: void resize(InputArray src, OutputArray dst, Size dsize, double fx=0, doub ...
- Java模式—适配器模式
适配器模式(Adapter): 1.概念:将一个类中的接口转换为客户希望的另外一个接口,使得原本由于接口不兼容而不能一起工作的那些类可以一起工作. 2.模式中的角色 1 目标接口:客户所期待的接口.目 ...
- Android使用bindService作为中间人对象开启服务
Android使用bindService作为中间人对象开启服务 项目结构如下: MyService: package com.demo.secondservice; import android.ap ...
- 帝国CMS-后台管理工具
后台管理工具 apache+mysql 搭建的后台管理工具 参考手册*************http://www.phome.net/doc/ecmsedu/ 1.安装----- 使用的一键安装包. ...
- idea terminal 修改为git bash 不支持中文
1.idea terminal 修改为git bash 由于IDEA自带的Terminal工具是Windows命令窗口cmd,在开发过程中需要用到一些常用的命令操作时要不断的在IDEA和git bas ...
- JavaScript -- Anchor
-----052-Anchor.html----- <!DOCTYPE html> <html> <head> <meta http-equiv=" ...
- js截取字符串的后几位数
代码如下: var str="abcdefghhhh";//截取后4位 str.substring(str.length-4):