CF2241A.Divide and Conquer

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two positive integers xx and yy.

You are allowed to perform the following operation any number of times (possibly zero):

  • Choose any positive integer zz such that zz divides xx;
  • Set x:=xzx := \frac{x}{z}.

Determine whether you can make xx exactly equal to yy using this operation.

给你两个正整数 xx 和 yy。

你可以执行以下操作任意次(包括零次):

  • 任选一个正整数 zz,使得 zz 整除 xx;
  • 将 xx 更新为 xz\frac{x}{z}。

判断是否可以通过上述操作使 xx 恰好等于 yy。

输入格式

The first line of the input contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases. The description of each test case follows.

The only line of each test case contains two space-separated integers xx and yy (1≤x,y≤1001 \le x, y \le 100).

输入的第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4),表示测试用例的数量。每个测试用例的描述如下。

每个测试用例仅有一行,包含两个以空格分隔的整数 xx 和 yy(1≤x,y≤1001 \le x, y \le 100)。

输出格式

For each test case, print "YES" if you can make xx exactly equal to yy 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).

对于每个测试用例,如果可以使 xx 恰好等于 yy,则输出 "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=2z = 2 makes x=122=6x = \frac{12}{2} = 6
  • Choosing z=3z = 3 makes x=63=2x = \frac{6}{3} = 2

Thus, we can make x=yx = y. Hence, output YES.

For the second test case, it can be shown that it is impossible to make xx equal to yy.

对于第一个测试用例:

  • 选择 z=2z = 2,则 x=122=6x = \frac{12}{2} = 6
  • 选择 z=3z = 3,则 x=63=2x = \frac{6}{3} = 2

因此,我们可以使 x=yx = y。故输出 YES。

对于第二个测试用例,可以证明无法使 xx 等于 yy。

输入解题思路,AI测评打分。不知道怎么写?

首页