Codeforces Round #426 The Meaningless Game
题目网址:http://codeforces.com/contest/834/problem/C
题目:

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).
6
2 4
75 45
8 8
16 16
247 994
1000000000 1000000
Yes
Yes
Yes
No
No
Yes 思路: 1.将两人得分相乘(最坏情况是1e9*1e9要用long long否则会爆精度)再开立方根一定是一个整数,且该数等于k1*k2…*kn。
2.两人分别mod该立方根会等于0。 代码:
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int t,a,b;
long long mul,nmul;
int j;
scanf("%d",&t);
while (t--) {
scanf("%d%d",&a,&b);
mul=1LL*a*b;//用1LL转换精度
j=(int)(pow(mul, *1.0/)+0.5);//pow运算的是浮点型,结果要加0.5再取整
nmul=1LL*j*j*j;
if(mul!=nmul) printf("No\n");
else if(a%j!= || b%j!=) printf("No\n");
else printf("Yes\n");
}
return ;
}
Codeforces Round #426 The Meaningless Game的更多相关文章
- CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)
/* CodeForces 834C - The Meaningless Game [ 分析,数学 ] | Codeforces Round #426 (Div. 2) 题意: 一对数字 a,b 能不 ...
- Codeforces Round #426 (Div. 2) C. The Meaningless Game
C. The Meaningless Game 题意: 两个人刚刚开始游戏的时候的分数, 都是一分, 然后随机一个人的分数扩大k倍,另一个扩大k的平方倍, 问给你一组最后得分,问能不能通过游戏得到这样 ...
- 【Codeforces Round #426 (Div. 2) C】The Meaningless Game
[Link]:http://codeforces.com/contest/834/problem/C [Description] 有一个两人游戏游戏; 游戏包括多轮,每一轮都有一个数字k,赢的人把自己 ...
- Codeforces Round #426 (Div. 1) A.The Meaningless Game (二分+数学)
题目链接: http://codeforces.com/problemset/problem/833/A 题意: 给你 \(a\) 和 \(b\),两个人初始化为 \(1\).两个人其中一方乘以 \( ...
- 【筛法求素数】Codeforces Round #426 (Div. 1) A. The Meaningless Game
先筛出来1000以内的素数. 枚举x^(1/3) 和 y^(1/3)以内的素因子,这样除完以后对于x和y剩下的因子,小的那个的平方必须等于大的. 然后判断每个素因数的次数之和是否为3的倍数,并且小的那 ...
- 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 ...
- Codeforces Round #426 (Div. 2)
http://codeforces.com/contest/834 A. The Useless Toy 题意: <,>,^,v这4个箭头符号,每一个都可以通过其他及其本身逆时针或者顺时针 ...
- Codeforces Round #426 (Div. 2)A B C题+赛后小结
最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...
- Codeforces Round #426 (Div. 2) A,B,C
A. The Useless Toy 题目链接:http://codeforces.com/contest/834/problem/A 思路: 水题 实现代码: #include<bits/st ...
随机推荐
- Elastic Stack 笔记(三)Kibana5.6 安装
博客地址:http://www.moonxy.com 一.前言 Kibana 是 Elastic Stack 公司推出的一个针对 Elasticsearch 的开源分析及可视化平台,可以搜索.查看存放 ...
- 【数据结构】Hash表
[数据结构]Hash表 Hash表也叫散列表,是一种线性数据结构.在一般情况下,可以用o(1)的时间复杂度进行数据的增删改查.在Java开发语言中,HashMap的底层就是一个散列表. 1. 什么是H ...
- day 12 特殊权限
1.suid (set uid) 特殊权限 suid优点: 可以让普通用户执行无法执行的命令 方便 suid缺点: 如果rm 为suid, 无论谁执行该命令,都能删除系统的任何 资源 set uid ...
- 实现一个正则表达式引擎in Python(一)
前言 项目地址:Regex in Python 开学摸鱼了几个礼拜,最近几天用Python造了一个正则表达式引擎的轮子,在这里记录分享一下. 实现目标 实现了所有基本语法 st = 'AS342abc ...
- DOM之事件(二)
今天详细讲解JavaScript中的常用事件类型和功能. 一 鼠标事件 1, click:点击事件 等同于mousedown+mouseup,不管这两个事件间隔多久,都会触发一次click事件. 2 ...
- JAVA设计模式---单例模式篇
单例模式(singleton):是JAVA中最简单的一种设计模式,属于创建型模式.所谓单例,就是整个程序有且仅有一个实例. 特点: 构造方法私有化 在本类中实例化一个对象作为本类的属性 对外提供一个访 ...
- Spring 梳理 -异常处理
Spring 提供了多种方式将异常转换为相应 Spring框架提供的通用异常,将异常转换为HTTP状态码 Spring默认会将自身抛出的异常自动映射到合适的状态码,如下是一些示例: 举个例子,当后端抛 ...
- QT两个窗口相互切换
信号(signals)与槽(slots)是QT重要机制,例子使用了C++11 lambda表达式进行了信号与槽的连接. 实现两个窗口通过点击按钮完成互相切换,注意子窗口只能发送信号,不能处理,所有信号 ...
- 自定义属性--JavaScript
1 - 获取属性值 element.属性 获取属性值 element.getAttribute('属性') 区别: element.属性 --获取内置属性(元素本身自带的属性) element.get ...
- Event Hub小白入门指南
Event Hub事件中心 本文的目的在于用最白的大白话,让你从“完全不懂”开始,理解什么是分布式大数据流平台Event Hub,并且理解它的关键概念,并且初步理解其收发数据API. 定义,Event ...