833A The Meaningless Game
1 second
256 megabytes
standard input
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.
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.
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).
6
2 4
75 45
8 8
16 16
247 994
1000000000 1000000
Yes
Yes
Yes
No
No
Yes
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的平方,喊得慢的乘k;
所以a*b就是k的三次方的倍数。
即只需判断a*b是否三次方数,开三次方后,是不是a和b的因子即可。
代码如下:
#include <cstdio>
#include <cmath>
int main(){
long long n;
long long a,b;
scanf("%lld",&n);
while(n--){
scanf("%lld %lld",&a,&b);
long long u=floor(pow(a*b,1.0/3.0)+0.5);
if(u*u*u==a*b&&!(a%u)&&!(b%u)) puts("Yes");
else puts("No");
}
return 0;
}
833A The Meaningless Game的更多相关文章
- Codeforces 833A The Meaningless Game - 数论 - 牛顿迭代法 - 二分法
Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting. T ...
- 【纯水题】CF 833A The Meaningless Game
题目大意 洛谷链接 现在两个人做游戏,每个人刚开始都是数字\(1\),谁赢了就能乘以\(k^2\),输的乘以\(k\),现在给你最终这两个人的得分,让你判断是否有这个可能,有可能的话输出Yes,否则输 ...
- Codeforces Round #426 (Div. 1) (ABCDE)
1. 833A The Meaningless Game 大意: 初始分数为$1$, 每轮选一个$k$, 赢的人乘$k^2$, 输的人乘$k$, 给定最终分数, 求判断是否成立. 判断一下$a\cdo ...
- 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 ...
- C. Meaningless Operations Codeforces Global Round 1 异或与运算,思维题
C. Meaningless Operations time limit per test 1 second memory limit per test 256 megabytes input sta ...
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
C. The Meaningless Game 题意: 两个人刚刚开始游戏的时候的分数, 都是一分, 然后随机一个人的分数扩大k倍,另一个扩大k的平方倍, 问给你一组最后得分,问能不能通过游戏得到这样 ...
- Codeforces 834C - The Meaningless Game
834C - The Meaningless Game 数学. 思路1:判断a•b能不能化成v3且a%v==0且b%v==0.v可以直接用pow求(或者用cbrt),也可以二分求:还可以用map映射预 ...
- A. The Meaningless Game(数学)
A. The Meaningless Game time limit per test:1 second memory limit per test:256 megabytes input:stand ...
- Codeforces Round #426 The Meaningless Game
题目网址:http://codeforces.com/contest/834/problem/C 题目: C. The Meaningless Game Slastyona and her loyal ...
随机推荐
- 解决maven中某些依赖无法下载,手动安装Maven依赖
<!--先下载jar包,然后在仓库中手动安装,下面是遇到的两个例子--> <!--第一个--> mvn install:install-file -Dfile=D:\kaptc ...
- 使用Azure Runbook 发送消息到Azure Storage Queue
客户需要定时发送信息到Azure Storage Queue,所以尝试使用Azure Runbook实现这个需求. 首先新增一个Azure Automation Account的资源. 因为要使用Az ...
- BeetleX大数据之产品分析服务
数据规模过于庞大?数据标签过多难以管理?增加新的分析维度需要配置?这些beetlex.io都能轻松解决,即导即用,数据标签自动管理,轻易实现多种维度数据分析处理.接下介绍BeetleX针对产品 ...
- JavaScript中的Promise【期约】[未完成]
JavaScript中的Promise[期约] 期约主要有两大用途 首先是抽象地表示一个异步操作.期约的状态代表期约是否完成. 比如,假设期约要向服务器发送一个 HTTP 请求.请求返回 200~29 ...
- JavaScript中的构造函数和原型!
JavaScript中的原型! 原型的内容是涉及到JavaScript中的构造函数的 每一个构造函数都有一个原型对象!prototype 他的作用是 共享方法!还可以扩展内置对象[对原来的内置对象进行 ...
- (Oracle)看懂Oracle执行计划(转载)
最近一直在跟Oracle打交道,从最初的一脸懵逼到现在的略有所知,也来总结一下自己最近所学,不定时更新ing- 一:什么是Oracle执行计划? 执行计划是一条查询语句在Oracle中的执行过程或访问 ...
- Vue中双向数据绑定是如何实现的?
vue 双向数据绑定是通过 数据劫持 结合 发布订阅模式的方式来实现的, 也就是说数据和视图同步,数据发生变化,视图跟着变化,视图变化,数据也随之发生改变:核心:关于VUE双向数据绑定,其核心是 Ob ...
- .Net 5 C# 反射(Reflection)
这里有个目录 什么是反射 有什么用?怎么用? 获取类型的类型信息. 获取泛型信息 获取程序集的信息 从已加载的程序集获取 Type 对象 查看类的信息 首尾呼应.重复强调.重要事情说三遍 后记 什么是 ...
- Python中单引号,双引号,三引号的区别
Python中的字符串一般用单引号('A'),双引号("A")和三引号('''A''')或者("""A""") 1.单引 ...
- ReentrantReadWriteLock读写锁简单原理案例证明
ReentrantReadWriteLock存在原因? 我们知道List的实现类ArrayList,LinkedList都是非线程安全的,Vector类通过用synchronized修饰方法保证了Li ...