CF2241A.Divide and Conquer
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two positive integers x and y.
You are allowed to perform the following operation any number of times (possibly zero):
- Choose any positive integer z such that z divides x;
- Set x:=zx.
Determine whether you can make x exactly equal to y using this operation.
给你两个正整数 x 和 y。
你可以执行以下操作任意次(包括零次):
- 任选一个正整数 z,使得 z 整除 x;
- 将 x 更新为 zx。
判断是否可以通过上述操作使 x 恰好等于 y。
输入格式
The first line of the input contains a single integer t (1≤t≤104) — the number of test cases. The description of each test case follows.
The only line of each test case contains two space-separated integers x and y (1≤x,y≤100).
输入的第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。每个测试用例的描述如下。
每个测试用例仅有一行,包含两个以空格分隔的整数 x 和 y(1≤x,y≤100)。
输出格式
For each test case, print "YES" if you can make x exactly equal to y and "NO" otherwise.
You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).
对于每个测试用例,如果可以使 x 恰好等于 y,则输出 "YES";否则输出 "NO"。
你可以以任意大小写形式输出 "YES" 和 "NO"(例如,字符串 "yEs"、"yes" 和 "Yes" 均会被识别为肯定回答)。
输入输出样例
输入#1
3 12 2 6 7 99 79
输出#1
YES NO NO
说明/提示
For the first test case,
- Choosing z=2 makes x=212=6
- Choosing z=3 makes x=36=2
Thus, we can make x=y. Hence, output YES.
For the second test case, it can be shown that it is impossible to make x equal to y.
对于第一个测试用例:
- 选择 z=2,则 x=212=6
- 选择 z=3,则 x=36=2
因此,我们可以使 x=y。故输出 YES。
对于第二个测试用例,可以证明无法使 x 等于 y。
输入解题思路,AI测评打分。不知道怎么写?