Plus and Multiply
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Plus and Multiply
题面翻译
有一个无穷大的正整数集合 ,该集合按下面所述方法生成:
- 数字 在集合 中。
- 若数字 在该集合中,那么数 和数 均在集合 中。(其中 与 为给定常数)
现在给出数 ,请判断 是否在集合 中(此处给出的 与 就是上述集合生成方法中的 和 ),若在请输出 Yes
,否则输出 No
。多组数据。
令数据组数为 ,那么有 ,。
题目描述
There is an infinite set generated as follows:
- is in this set.
- If is in this set, and both are in this set.
For example, when and , the five smallest elements of the set are:
- ,
- ( is in this set, so is in this set),
- ( is in this set, so is in this set),
- ( is in this set, so is in this set),
- ( is in this set, so is in this set).
Given positive integers , , , determine if is in this set.
输入格式
The input consists of multiple test cases. The first line contains an integer ( ) — the number of test cases. The description of the test cases follows.
The only line describing each test case contains three integers , , ( ) separated by a single space.
输出格式
For each test case, print "Yes" if is in this set, and "No" otherwise. You can print each letter in any case.
样例 #1
样例输入 #1
5
24 3 5
10 3 6
2345 1 4
19260817 394 485
19260817 233 264
样例输出 #1
Yes
No
Yes
No
Yes
提示
In the first test case, is generated as follows:
- is in this set, so and are in this set;
- is in this set, so and are in this set;
- is in this set, so and are in this set.
Thus we can see is in this set.
The five smallest elements of the set in the second test case is described in statements. We can see that isn't among them.