Codeforces Round #426 (Div. 2) C. The Meaningless Game
来源:互联网 发布:如何消除身体疲劳知乎 编辑:程序博客网 时间:2024/06/04 22:40
【题目链接】codeforces#
【题意】两人玩游戏,初始都是1分,每一局之后,赢的人*K^2,输的人*K,给出若干组比赛结果,问是否可能发生。
【样例】
Input
62 475 458 816 16247 9941000000000 1000000
Output
YesYesYesNoNoYes
【分析】每一局都有一个人*K^2,有一个人*K,可以想到,两人的积分之积就是所有K^3的积。题目里说k是a natural number。所以对积分之积开三次方,算出∏k,再判断能否被两个积分整除就可以了。开三次方用的是pow(x,1.0/3);关键的地方就是处理这个数据,比如样例里的75,45,直接输出pow函数的值是14.99999而不是15,可见pow函数的计算是不完全精确的。这里我直接用用了ceil向上取整,就解决了这个问题。取整的问题真的很重要啊,这题挺简单的,很多人应该都是卡在这里了吧。
#include<cstdio>#include<algorithm>#include<iostream>#include<cmath>using namespace std;int main(){ int n; int a,b; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d%d",&a,&b); double x=pow(a,1.0/3); double y=pow(b,1.0/3); int z=ceil(x*y); if(a%z==0&&b%z==0) printf("YES\n"); else printf("NO\n"); } return 0;}
阅读全文
0 0
- Codeforces Round #426 (Div. 2) C. The Meaningless Game C. The Meaningless Game
- (Codeforces Round #426 (Div. 2)) C.The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #426 (Div. 2)-C. The Meaningless Game
- Codeforces Round #426 (Div. 2) C The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- Codeforces Round #426 (Div. 2) C The Meaningless Game
- Codeforces Round #426 (Div. 2) C:The Meaningless Game The Meaningless Game
- Codeforces Round #426 (Div. 2)The Meaningless Game(思维+二分)
- Codeforces Round #426 (Div. 2)The Meaningless Game(思维+二分)
- Codeforces Round #426 (Div. 2)The Meaningless Game【数学题】【水题】
- Codeforces Round #426 (Div. 2)The Meaningless Game(思维+二分)
- Codeforces Round #426 (Div. 2) C. The Meaningless Game 思维 D. The Bakery dp
- Codeforces Round #426 (Div. 2) B.The Festive Evening+C.The Meaningless Game
- C. The Meaningless Game(Codeforces Round #426 (Div. 2) C)
- Codeforces Round #426 (Div. 2) C. The Meaningless Game & A, B题代码及错误总结
- Codeforces Round #426 (Div. 2) A B C The Meaningless Game
- 时间和时间戳之间的转换
- 从小到大排序1(for循环法)
- leetcode:path-sum
- Play 2.0 中文资料
- ssm中Invalid bound statement (not found)错误的处理(IDEA中)
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
- 调试代码时免重复输入数据
- 面试题:替换空格
- Zookeeper client
- FileChannel 传输(zero-copy 的基础)
- word-break:break-all和word-wrap:break-word的区别
- C# windows服务没有RunInstallerAttribute.Yes的公共安装程序
- Spring Security 与 Oauth2 整合 步骤
- 传颜色生成图片