CF1647D.Madoka and the Best School in Russia

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Madoka is going to enroll in "TSUNS PTU". But she stumbled upon a difficult task during the entrance computer science exam:

  • A number is called good if it is a multiple of dd.
  • A number is called beatiful if it is good and it cannot be represented as a product of two good numbers.

Notice that a beautiful number must be good.

Given a good number xx, determine whether it can be represented in at least two different ways as a product of several (possibly, one) beautiful numbers. Two ways are different if the sets of numbers used are different.

Solve this problem for Madoka and help her to enroll in the best school in Russia!

魔笛将要报考“TSUNS PTU”大学。但在入学计算机科学考试中,她遇到了一道难题:

  • 若一个数是 dd 的倍数,则称其为好数;
  • 若一个数既是好数,又不能表示为两个好数的乘积,则称其为美数。

注意:美数必为好数。

给定一个好数 xx,判断它是否能以至少两种不同的方式表示为若干个(可能只有一个)美数的乘积。若所使用的数的集合不同,则称这两种方式不同。

请帮魔笛解决这道题,助她考入俄罗斯最顶尖的学府!

输入格式

The first line contains a single integer tt (1≤t≤1001 \leq t \leq 100) — number of test cases. Below comes their description.

Each test case consists of two integers xx and dd, separated by a space (2≤x,d≤1092 \leq x, d \leq 10^9). It is guaranteed that xx is a multiple of dd.

第一行包含一个整数 tt(1≤t≤1001 \leq t \leq 100),表示测试用例的数量。接下来是各测试用例的描述。

每个测试用例包含两个由空格分隔的整数 xx 和 dd(2≤x,d≤1092 \leq x, d \leq 10^9)。保证 xx 是 dd 的倍数。

输出格式

For each set of input data, output "NO" if the number cannot be represented in at least two ways. Otherwise, output "YES".

You can output each letter in any case (for example, "YES", "Yes", "yes", "yEs", "yEs" will be recognized as a positive answer).

对于每组输入数据,若该数无法以至少两种方式表示,则输出“NO”;否则输出“YES”。

您可以以任意大小写形式输出每个字母(例如,“YES”、“Yes”、“yes”、“yEs”、“yEs”均被视为肯定回答)。

输入输出样例

  • 输入#1

    8
    6 2
    12 2
    36 2
    8 2
    1000 10
    2376 6
    128 4
    16384 4

    输出#1

    NO
    NO
    YES
    NO
    YES
    YES
    NO
    YES

说明/提示

In the first example, 66 can be represented as 66, 1⋅61 \cdot 6, 2⋅32 \cdot 3. But 33 and 11 are not a good numbers because they are not divisible by 22, so there is only one way.

In the second example, 1212 can be represented as 6⋅26 \cdot 2, 1212, 3⋅43 \cdot 4, or 3⋅2⋅23 \cdot 2 \cdot 2. The first option is suitable. The second is— no, because 1212 is not beautiful number (12=6⋅212 = 6 \cdot 2). The third and fourth are also not suitable, because 33 is not good number.

In the third example, 3636 can be represented as 18⋅218 \cdot 2 and 6⋅66 \cdot 6. Therefore it can be decomposed in at least two ways.

在第一个例子中,66 可以表示为 66、1⋅61 \cdot 6、2⋅32 \cdot 3。但 33 和 11 不是“好”数,因为它们不能被 22 整除,因此只有一种表示方式。

在第二个例子中,1212 可以表示为 6⋅26 \cdot 2、1212、3⋅43 \cdot 4 或 3⋅2⋅23 \cdot 2 \cdot 2。第一种表示方式是可行的。第二种不可行,因为 1212 不是“优美”数(12=6⋅212 = 6 \cdot 2)。第三和第四种也不可行,因为 33 不是“好”数。

在第三个例子中,3636 可以表示为 18⋅218 \cdot 2 和 6⋅66 \cdot 6。因此它至少有两种分解方式。

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

首页