题目链接: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. mysqli使用localhost问题

    <?php $mysqli = new mysqli('localhost', 'root', '123456', 'mysql'); if ($mysqli->connect_error ...

  2. spring cloud:HystrixDashboard

    hystrix-dashboard-server 1. File-->new spring starter project 2.add dependency <parent> < ...

  3. 火狐使用阿里云OOS上传图片报错:“XML 解析错误:找不到根元素”

    问题描述: 使用阿里云OOS上传图片在火狐浏览器报错 "XML 解析错误:找不到根元素",但不影响功能的使用.阿里云返回信息: <Error> <Code> ...

  4. TCP中SYN洪水攻击

    在查看TCP标识位SYN时,顺便关注了一下SYN Flood,从网上查阅一些资料加以整理,SYN洪水攻击利用TCP三次握手. 1.SYN洪水介绍 当一个系统(客户端C)尝试和一个提供了服务的系统(服务 ...

  5. python string_1

    quote :http://www.runoob.com/python/python-strings.html #coding:utf-8 s1="http://www.jnshu.com/ ...

  6. 使用TestNG框架测试用例执行顺序问题

    既然是讨论执行顺序问题,那么用例肯定是批量执行的,批量执行的方法有mvn test.直接运行testng.xml文件,其中直接运行testng.xml文件的效果与pom文件中配置执行testng.xm ...

  7. SPA应用性能优化(懒加载)

    前提: 如今开发方式都是采用前后台分离的方式,前台采用的方式则是单页面应用开发简称SPA,这种开发模式最大的一个特点就是将有所代码打包成了一个文件, 这会导致了一个问题就是如果这个应用过大,打出来的这 ...

  8. Scratch少儿编程系列:(二)界面介绍及相关概念

    本系列后续所有Scratch的讲解均基于2.0版本介绍.系统启动后,界面如下: Scratch主要包括6个区域: 1. 菜单:新建.打开.保存 Scratch文件,2.0版本文件后缀名为 .sb2 2 ...

  9. Pytorch搭建卷积神经网络用于MNIST分类

    import torch from torch.utils.data import DataLoader from torchvision import datasets from torchvisi ...

  10. Spring Security Session Time Out

    最近在用Spring Security做登录管理,登陆成功后,页面长时间无操作,超过session的有效期后,再次点击页面操作,页面无反应,需重新登录后才可正常使用系统. 为了优化用户体验,使得在se ...