题目链接:http://codeforces.com/contest/834/problem/C

题意:两个在玩一个游戏,对于每一轮,选定一个自然是k,初始两人的分数都为1,每一个回合赢的人在他当前分数的基础上乘以k^2,输的人在他当前分数的基础上乘以k,现在经过若干回合后他们的分数分别是a,b问你这个a,b是否合法。

思路:首先对于每一个回合,赢的人乘以k^2,输的人乘以k,那么对于k来说每一个回合对于两个的总贡献就是k^3,不管3个k怎么分配的这两个人。所以两个人的总分数(a*b)一定是一个三次方数。 所以可以二分k,找到一个k满足k^3==a*b。 并且还要满足a%k==0&&b%k==0,因为每次a和b都是乘以k(不管乘了1次还是2次),所以a和b一定要是k的倍数。

#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<time.h>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long int LL;
const int MAXN = 1e6 + ;
const int INF = 1e9;
const int mod = 1e9 + ;
int main(){
#ifdef kirito
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int n, a, b;
while (~scanf("%d", &n)){
for (int i = ; i <= n; i++){
scanf("%d%d", &a, &b);
int l = , r = , mid;
while (r >= l){
mid = (l + r) >> ;
if (1LL * mid*mid*mid >= 1LL * a*b){
r = mid - ;
}
else{
l = mid + ;
}
}
int k = l;
if ((1LL * k*k*k == 1LL * a*b) && (a%k == ) && (b%k == )){
printf("Yes\n");
}
else{
printf("No\n");
}
}
}
return ;
}

Codeforces Round #426 (Div. 2) - C的更多相关文章

  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)【A.枚举,B.思维,C,二分+数学】

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

  3. Codeforces Round #426 (Div. 2)

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

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

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

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

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

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

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

  7. Codeforces Round #426 (Div. 2)A题&&B题&&C题

    A. The Useless Toy:http://codeforces.com/contest/834/problem/A 题目意思:给你两个字符,还有一个n,问你旋转n次以后从字符a变成b,是顺时 ...

  8. 【Codeforces Round #426 (Div. 2) A】The Useless Toy

    [Link]:http://codeforces.com/contest/834/problem/A [Description] [Solution] 开个大小为4的常量字符数组; +n然后余4,-n ...

  9. 【Codeforces Round #426 (Div. 2) B】The Festive Evening

    [Link]:http://codeforces.com/contest/834/problem/B [Description] [Solution] 模拟水题; 注意一个字母单个出现的时候,结束和开 ...

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

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

随机推荐

  1. 【Python】学习笔记十二:模块

    模块(module) 在Python中,一个.py文件就是一个模块.通过模块,你可以调用其它文件中的程序 引入模块 先写一个first.py文件,内容如下: def letter(): print(' ...

  2. springboot上传文件大小限制的配置

    springboot配置文件: application.properties #配置文件传输 spring.servlet.multipart.enabled =true spring.servlet ...

  3. legend3---PHP使用阿里云短信服务

    legend3---PHP使用阿里云短信服务 一.总结 一句话总结: 使用步骤照官方文档,代码拷贝即可 1.php使用阿里云短信服务的步骤? 入驻阿里云->开通短信服务->获取Access ...

  4. Jupiter Code Review Reference -- Jupiter代码审查工具使用参考

    Jupiter Code Review Reference -- Jupiter代码审查工具使用参考 (修改版) 原创 2010年07月06日 10:43:00 标签: 审查 / reference  ...

  5. nodejs 简单的搭建一个服务器

    前言: nodejs 主要是后台语言  node 是在终端运行的,所以他可以进行 dos 命令 模块 自定义 JavaScript 是前台语言 nodejs 是 也是使用我们的 JavaScript ...

  6. 清理docker 容器下面的log

    1. docker info 找到docker root dir 2. go to /var/lib/docker 3. constainers 下面有每个容器的文件夹,-json.log 结尾的为L ...

  7. Eigen中的矩阵及向量运算

    Eigen中的矩阵及向量运算 ,[+,+=,-,-=] ,[\*,\*=] ,[.transpose()] ,[.dot(),.cross(),.adjoint()] ,针对矩阵元素进行的操作[.su ...

  8. win 10 hosts文件不生效

    win 10 hosts文件不生效       windows 10 hosts文件修改了,但是怎么都无法在浏览器中进行解析.一直都在等待,直到链接超时. 最后解决办法: 把hosts文件内容复制出来 ...

  9. VC CString,int,string,char*之间的转换

    CString转string : CString strMfc = "test"; std::string strStr; strStr = strMfc.GetBuffer(); ...

  10. apache-httpd2.4编译安装

    centos 6 编译安装httpd-2.4 centos6yum安装的apr版本已经不适用httpd-2.4版本了.所以,需要源码编译apr以及apr-util1. 下载源码:cd /usr/loc ...