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的更多相关文章
随机推荐
- 彻底弄懂“PKIX path building failed”问题
SSL的基础知识 SSL的全称是Secure Socket Layer.它的通信流程如下图所示,客户端与服务端会通过几次通信,通过非对称加密创建出一个加密密钥,用于以后的对称信息加密. 1,客户端明文 ...
- python传输文件
传输文件简单版 server端: import socket import struct import json import os share_dir = r'C:\py3Project\路飞\第三 ...
- oracle 闪回、归档的设置建议
闪回与归档的相关测试 参考博客:http://www.cnblogs.com/hellojesson/p/7050097.html 数据库在归档模式下的管理 参考博客:http://www.cnblo ...
- 重启tomcat服务操作
1. 进入linux系统下tomcat的bin目录,比如:cd /usr/local/apache-tomcat-7.0.42/bin 2. 关闭一下tomcat服务,特别是已经启动的情况下,只不过有 ...
- Elasticsearch使用filter进行匹配关系and,or,not,range查询
RESTful接口URL的格式: http://localhost:9200/<index>/<type>/[<id>] 其中index.type是必须提供的. i ...
- (转)Linux 系统监控、诊断工具之 top命令详解
原文:https://www.linuxidc.com/Linux/2014-12/110563.htm 目录 (1)系统.任务统计信息:(2)进程. cpu 统计信息:(3)最后两行为内存信息:3. ...
- puppet的使用:依赖关系整理
title: date: 2016-05-08 21:45:33 tags: puppet categories: 技术 puppet中的依赖关系整理. 概述 puppet中的依赖关系大概有如下几个: ...
- gridvew使用技巧2
GridVew1_RowDataBindGridView1.DataKeys[e.Row.RowIndex].Values[].ToString(); foreach (GridViewRow t i ...
- Python学习--12 异常处理、调试
异常捕获 语法格式: try: pass except xxx as e: pass except xxx as e: pass ... else: pass finally: pass except ...
- 安装python-devel开发包
1.概述 有时在安装某些软件的时候,会报错: Error: must have python development packages -devel, python2.-devel, python2. ...