题目网址:http://codeforces.com/contest/834/problem/C

题目:

C. 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 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 思路: 1.将两人得分相乘(最坏情况是1e9*1e9要用long long否则会爆精度)再开立方根一定是一个整数,且该数等于k1*k2…*kn。
2.两人分别mod该立方根会等于0。 代码:
 #include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int t,a,b;
long long mul,nmul;
int j;
scanf("%d",&t);
while (t--) {
scanf("%d%d",&a,&b);
mul=1LL*a*b;//用1LL转换精度
j=(int)(pow(mul, *1.0/)+0.5);//pow运算的是浮点型,结果要加0.5再取整
nmul=1LL*j*j*j;
if(mul!=nmul) printf("No\n");
else if(a%j!= || b%j!=) printf("No\n");
else printf("Yes\n");
}
return ;
}

 

Codeforces Round #426 The Meaningless Game的更多相关文章

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

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

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

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

  3. 【Codeforces Round #426 (Div. 2) C】The Meaningless Game

    [Link]:http://codeforces.com/contest/834/problem/C [Description] 有一个两人游戏游戏; 游戏包括多轮,每一轮都有一个数字k,赢的人把自己 ...

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

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

  5. 【筛法求素数】Codeforces Round #426 (Div. 1) A. The Meaningless Game

    先筛出来1000以内的素数. 枚举x^(1/3) 和 y^(1/3)以内的素因子,这样除完以后对于x和y剩下的因子,小的那个的平方必须等于大的. 然后判断每个素因数的次数之和是否为3的倍数,并且小的那 ...

  6. Codeforces Round #426 (Div. 2)【A.枚举,B.思维,C,二分+数学】

    A. The Useless Toy time limit per test:1 second memory limit per test:256 megabytes input:standard i ...

  7. Codeforces Round #426 (Div. 2)

    http://codeforces.com/contest/834 A. The Useless Toy 题意: <,>,^,v这4个箭头符号,每一个都可以通过其他及其本身逆时针或者顺时针 ...

  8. Codeforces Round #426 (Div. 2)A B C题+赛后小结

    最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...

  9. Codeforces Round #426 (Div. 2) A,B,C

    A. The Useless Toy 题目链接:http://codeforces.com/contest/834/problem/A 思路: 水题 实现代码: #include<bits/st ...

随机推荐

  1. Spring Boot (四): Druid 连接池密码加密与监控

    在上一篇文章<Spring Boot (三): ORM 框架 JPA 与连接池 Hikari> 我们介绍了 JPA 与连接池 Hikari 的整合使用,在国内使用比较多的连接池还有一个是阿 ...

  2. [LeetCode] 由 “打印机任务队列" 所想

    一.这是个基础问题 Ref: Python之队列模拟算法(打印机问题)[首先研究这个问题作为开始] 任务队列 定义一个任务队列,来管理任务,而无需关心队列的”任务类型". # 自定义队列类 ...

  3. JQuery对于动态生成的标签绑定事件失效

    JQuery对整个html文档进行dom操作后,我们要想动态绑定事件,有两种方法 1.在进行dom操作时,在标签中写上onclick="afun()" 2.利用document的操 ...

  4. Hive安装与简单使用并集成SparkSQL

    ## Hive环境搭建1. hive下载:http://archive-primary.cloudera.com/cdh5/cdh/5/hive-1.1.0-cdh5.7.0.tar.gzwget h ...

  5. uni-app实现滑动切换效果

    在对于uni-app框架了解之后,今天就实现一个滚动切换tab效果,这个很常见的一个效果,最后封装成一个组件,便于以后使用,写这个需要引入uni官方提供的uni.css样式,用到了写好的样式,就不需要 ...

  6. Spark的Java开发环境构建

    为开发和调试SPark应用程序设置的完整的开发环境.这里,我们将使用Java,其实SPark还支持使用Scala, Python和R.我们将使用IntelliJ作为IDE,因为我们对于eclipse再 ...

  7. 面试官:都说阻塞 I/O 模型将会使线程休眠,为什么 Java 线程状态却是 RUNNABLE?

    摘要: 原创出处 https://studyidea.cn 「公众号:程序通事 」欢迎关注和转载,保留摘要,谢谢! 使用 Java 阻塞 I/O 模型读取数据,将会导致线程阻塞,线程将会进入休眠,从而 ...

  8. centos7 远程连接其他服务器redis

    在本地远程连接 在终端输入: redis-cli -h 服务器ip地址 -p 端口 -a 密码

  9. css实现斜角效果

    重点代码: 使用一张图片盖住div,实现斜角效果 .triangle { position: absolute; top:; left:; width: 36px; height: 36px; bac ...

  10. 关于win10、ubuntu双系统安装的 geom erro错误

    安装参考这个博客:http://blog.csdn.net/pop_rain/article/details/70477085 只记录安装ubuntu过程遇到的问题: 1.分区不可用(分区按以下设置) ...