Codeforces Round #426 (Div. 2) C The Meaningless Game
来源:互联网 发布:阿里云 英国节点 编辑:程序博客网 时间:2024/06/07 20:31
假设选了五个数,分别是k1,k2,k3,k4,k5
a = k1*k2*k2*k3*k4*k4*k5
b = k1*k1*k2*k3*k3*k4*k5*k5
a*b=k1^3 * k2^3 * k3^3 * k4^3 *k5^3
a,b<=10^9,a*b<=10^18,a*b开三次根号就是10^6
在(1,10^6)内二分,找到mid^3 = a*b,并且a%mid=0,b%mid=0
#include <stdio.h>typedef long long LL;const LL MAXN = 1e6;LL a,b;bool flag;int main(){ int n; LL mul; scanf("%d",&n); while(n--) { flag = true; scanf("%I64d %I64d",&a,&b); mul = a*b; LL l = 1; LL r = MAXN; LL mid = (l+r) >> 1; while(l <= r) { if(mid*mid*mid > mul) r = mid-1; else if(mid*mid*mid < mul) l = mid+1; else if(a%mid == 0 && b%mid == 0) { printf("Yes\n"); flag = false; break; } else break; mid = (l+r) >> 1; } if(flag) 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
- ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe
- android休眠唤醒流程:
- GCC内嵌汇编一些限制字符串
- 将excel中的内容导入mysql中
- 用Intillij IDEA实现MyBatis逆向工程
- Codeforces Round #426 (Div. 2) C The Meaningless Game
- jar、war、ear包的作用和区别
- Eclipse将引用了第三方jar包的Java项目打包成jar文件的两种方法
- 计算机网络之运输层零散知识点
- C++学习-类
- php如何判断文件是否存在,包括本地和远程文件
- Android中判断当前线程是否是主线程
- Html整理
- canvas生成图片所遇到的坑