Codeforces Round 777 (Div. 2)
D
Madoka and the Best School in Russia
Codeforces
1900
原题
← CE →
翻译中…

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 $d$.
  • 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 $x$, 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!

翻译中…

Input

翻译中…

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

翻译中…

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

翻译中…

Output

翻译中…

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).

翻译中…

Note

翻译中…

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

翻译中…

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

翻译中…

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

翻译中…

样例

Input #1
8
6 2
12 2
36 2
8 2
1000 10
2376 6
128 4
16384 4
Output #1
NO
NO
YES
NO
YES
YES
NO
YES
InputCopy OutputCopy
题目信息
题号
1647D
时间限制
2 s
内存限制
256 MB
标签
构造
动态规划
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。