Codeforces833A
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
input
6
2 4
75 45
8 8
16 16
247 994
1000000000 1000000
output
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则可以,否则不可以。
//2017-08-16
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long using namespace std; int main()
{
int n;
ll a, b, c;
while(scanf("%d", &n)!=EOF){
for(int i = ; i < n; i++){
scanf("%I64d%I64d", &a, &b);
c = ceil(pow(a*b, 1.0/));//ceil为向上取整函数
if(c*c*c == a*b && a%c== && b%c==)
printf("Yes\n");
else printf("No\n");
}
} return ;
}
Codeforces833A的更多相关文章
随机推荐
- UVA12888 【Count LCM】(莫比乌斯反演)
题意:求\(\sum_{i=1}^{n}\sum_{j=1}^{m}[gcd(i,j)==1]\) \(assume\ n<m\) \(\sum_{i=1}^{n}\sum_{j=1}^{m}[ ...
- 货车运输(最大生成树+倍增LCA)
看到第一篇题解的神奇码风--我决定发一篇码风正常的题解造福人类 这题的做法也非常经典,最大生成树\(+LCA\),相当于先贪心一下,在LCA的时候记录一下当前最小的边权 顺便吐槽一下最后一个测试点: ...
- Django(母版和继承)
day66 参考:http://www.cnblogs.com/liwenzhou/p/7931828.html#autoid-2-3-6 内容回顾 1. 模板系统(字符串替换) ...
- AjaxResult
package com.sprucetec.tms.utils; /** * AjaxReturn * * @author Yinqiang Du * @date 2016/7/12 */import ...
- java项目打成jar包使用
使用Eclipse打成jar包 1.创建项目hello 2.写java文件 package hell; import java.io.PrintStream; public class Hello { ...
- 2. GitHub远程仓库
1. GitHub ssh-keygen -t rsa -C "youremail@example.com" 之后再用户主目录里会有隐藏的.ssh目录,里面有id_r ...
- ProxySQL 部署 Single Writer Failover 读写分离 (PXC)
主机信息: Proxysql: 如果你忽略了ProxySQL会报告主机组的变化,我建议把它设置为0,除非你试图调试"某些东西",否则你的日志将很快变得巨大.UPDATE globa ...
- 采用太平洋AI集装箱箱号识别接口实现集装箱箱号识别
识别 示例图片 1 太平洋AI集装箱箱号识别接口(文档下方有详细操作指南) 1.1 接口一:提交base64格式的图片 地址:http://218.1.125.60:88/container_num_ ...
- IntelliJ IDEA中Debug的使用技巧
当运行结果跟我们设想的不一致时,我们就可以用debug进行代码调试,下面是我在日常开发中对debug的一些小结 (一)基本介绍 本篇文章是基于IntelliJ IDEA2018.3.2版本,Debug ...
- oracle跨平台数据迁移 expdp/impdp 字符集问题 导致ORA-02374 ORA-12899 ORA-02372
环境描述: 源数据库环境: 操作系统:Windows SERVER 2008R2 数据库版本:单实例 ORACLE 11.2.0.1 目标端数据库环境: 操作系统:redhat ...