Codeforces 833A-The Meaningless Game
来源:互联网 发布:淘宝充值没到账怎么办 编辑:程序博客网 时间:2024/06/07 00:07
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).
62 475 458 816 16247 9941000000000 1000000
YesYesYesNoNoYes
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^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数
解题思路:将两个人的分数相乘然后开立方即可
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <cmath>#include <map>#include <set>#include <stack>#include <queue>#include <vector>#include <bitset>#include <functional>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;int n;LL a,b;int main(){ while(~scanf("%d",&n)) { while(n--) { scanf("%lld%lld",&a,&b); LL c=a*b; c=round(pow((double)c,1.0/3)); if(c*c*c!=a*b||a%c||b%c) printf("No\n"); else printf("Yes\n"); } } return 0;}
- Codeforces Round 833A-The Meaningless Game
- Codeforces 833A-The Meaningless Game
- CodeForces 833 A.The Meaningless Game(水~)
- codeforces 426 Div2C 833A The Meaningless Game(二分||数学)
- CodeFroces 833A. The Meaningless Game(数学)
- The Meaningless Game 【codeforces】【思维】
- Codeforces Round #426 (Div. 1) A. The Meaningless Game
- 【Codeforces】834C. The Meaningless Game
- 【CodeForces】426Div2 C The Meaningless Game
- codeforces 834C (The Meaningless Game)
- CodeForces #426 div2 C The Meaningless Game
- Codeforces 834C The Meaningless Game【思维】
- codeforces 834 C The Meaningless Game
- codeforces The Meaningless Game 数学思维
- codeforces 834 C The Meaningless Game
- CodeForces 834C The Meaningless Game
- CodeForces 834 C. The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game & A, B题代码及错误总结
- Ubuntu下忘记MySQL root密码解决方法
- 数据库SQL实战
- pxe
- 查找算法(1)基本概念
- .NET Framework 处理XML操作技巧(下)
- Codeforces 833A-The Meaningless Game
- 命令行SVN根据版本号查看文件路径
- NodeJS基础API搭建服务器详细过程记录
- python列表list
- 程序员高效率办公软件(推荐)。
- LeetCode--Search for a Range
- 方正科技的发家历程
- 自动打包批处理
- 【华为机试】按字节截取字符串