A. The Meaningless Game(数学)
A. The Meaningless Game
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.
Input
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.
Output
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).
Example
6
2 4
75 45
8 8
16 16
247 994
1000000000 1000000
Yes
Yes
Yes
No
No
Yes
Note
First game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.
The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.
a×b能开立方根并且立方根同时整除a、b则可以,否则不可以
#include<cstdio>
#include<cmath>
#define ll long long int main()
{
int n;
scanf("%d",&n);
while(n--)
{
ll a,b;//注意数值类型
scanf("%I64d%I64d",&a,&b);
ll ans = ceil(pow(a*b, 1.0/3));//向上取整
if(ans*ans*ans == a*b && a%ans == 0 && b%ans ==0)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
真的好神奇!!!
A. The Meaningless Game(数学)的更多相关文章
- Codeforces 834C - The Meaningless Game
834C - The Meaningless Game 数学. 思路1:判断a•b能不能化成v3且a%v==0且b%v==0.v可以直接用pow求(或者用cbrt),也可以二分求:还可以用map映射预 ...
- Code Forces 833 A The Meaningless Game(思维,数学)
Code Forces 833 A The Meaningless Game 题目大意 有两个人玩游戏,每轮给出一个自然数k,赢得人乘k^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数 ...
- Codeforces Round #426 (Div. 1) A.The Meaningless Game (二分+数学)
题目链接: http://codeforces.com/problemset/problem/833/A 题意: 给你 \(a\) 和 \(b\),两个人初始化为 \(1\).两个人其中一方乘以 \( ...
- CodeForces 834C - The Meaningless Game | Codeforces Round #426 (Div. 2)
/* CodeForces 834C - The Meaningless Game [ 分析,数学 ] | Codeforces Round #426 (Div. 2) 题意: 一对数字 a,b 能不 ...
- 数学思想:为何我们把 x²读作x平方
要弄清楚这个问题,我们得先认识一个人.古希腊大数学家 欧多克索斯,其在整个古代仅次于阿基米德,是一位天文学家.医生.几何学家.立法家和地理学家. 为何我们把 x²读作x平方呢? 古希腊时代,越来越多的 ...
- 速算1/Sqrt(x)背后的数学原理
概述 平方根倒数速算法,是用于快速计算1/Sqrt(x)的值的一种算法,在这里x需取符合IEEE 754标准格式的32位正浮点数.让我们先来看这段代码: float Q_rsqrt( float nu ...
- MarkDown+LaTex 数学内容编辑样例收集
$\color{green}{MarkDown+LaTex 数学内容编辑样例收集}$ 1.大小标题的居中,大小,颜色 [例1] $\color{Blue}{一元二次方程根的分布}$ $\color{R ...
- 深度学习笔记——PCA原理与数学推倒详解
PCA目的:这里举个例子,如果假设我有m个点,{x(1),...,x(m)},那么我要将它们存在我的内存中,或者要对着m个点进行一次机器学习,但是这m个点的维度太大了,如果要进行机器学习的话参数太多, ...
- Sql Server函数全解<二>数学函数
阅读目录 1.绝对值函数ABS(x)和返回圆周率的函数PI() 2.平方根函数SQRT(x) 3.获取随机函数的函数RAND()和RAND(x) 4.四舍五入函数ROUND(x,y) 5.符号函数SI ...
随机推荐
- go cobra
https://github.com/spf13/cobra https://github.com/spf13/cobra/blob/master/bash_completions.md go get ...
- Centos7安装jekyll
1.首先需要安装相应的依赖包及所需要的工具 sudo yum install nodejs npm ruby ruby-devel rubygems git 2.修改gem源 国内 使用的淘宝的更新源 ...
- BarcodeLib -- 一个精简而不失优雅的条形码生成库
BarcodeLib -- 一个精简而不失优雅的条形码生成库 引言 在百度进行“C# 条形码”等类似关键字搜索的时候,基本上是使用 ZXing 类库进行条形码的生成.今天我所介绍的是另一款类库 Bar ...
- 【BZOJ3926】诸神眷顾的幻想乡 【广义后缀自动机】
题意 给定一棵树,每个结点有一个颜色,问树上有多少种子串(定义子串为两点上路径颜色的序列).保证叶子结点<=20 分析 我们可以发现一个结论,任意一个子串一定是以某个叶子结点为根的trie的后缀 ...
- UGUI防止穿透和判断点击的是否是UI
用UGUI做的UI,比如按钮,点击一下,后面的3D物体也会接收到点击事件! 1.UGUI自带的防穿透代码: if (EventSystem.current.IsPointerOverGameObjec ...
- ubuntu eclipse opencv环境配置
项目——Properties——C/C++ Build——Settings 配置包含目录: GCC C++ Compiler ——Includes /usr/include /usr/local/ ...
- c# 类中使用ResolveUrl
类中使用ResolveUrl 1>获取当前page然后调用ResolveUrl System.Web.UI.Page page = HttpContext.Current.CurrentHand ...
- 隐藏在default construct后面的是什么
C++新手很容易陷入两个认识上的误区: 1.任何类如果不显示的定义一个构造函数那么编译器就会构造出一个默认构造函数. 2.默认构造函数负责类的所有数据成员的初始化,显然不是这样的. 为什么不是这样的, ...
- PHP发红包程序限制红包的大小
我们先来分析下规律. 设定总金额为10元,有N个人随机领取: N=1 第一个 则红包金额=X元: N=2 第二个 为保证第二个红包可以正常发出,第一个红包金额=0.01至9.99之间的某个随机数. 第 ...
- Java 前台后台数据传递、中文乱码解决方法
1.向前台传递数据;2.向后台传递数据;3.ajax post 提交数据到服务端时中文乱码解决方法;4.数组类型参数传递; 1.向前台传递数据:1.1 字符串数据传递: 这种方式只是单一的向前台传递 ...