#P5605. 小 A 与两位神仙
小 A 与两位神仙
Description
One day, Little A was walking home after school when he suddenly met two immortal dream-makers, Zaomengzhe and Jeremy. As soon as they saw Little A, they said they wanted to play a game with him. Little A was covered in golden light and, for some reason, agreed to their request.
The rules of the game are as follows: the two immortals first choose a positive integer , and guarantee that is a positive integer power of an odd prime . Then they play rounds. In each round, Zaomengzhe chooses a positive integer , and Jeremy chooses a positive integer , with and , meaning is coprime to and is coprime to . Then they ask Little A whether there exists a non-negative integer such that .
The immortals say that only if Little A answers correctly in every round can he return to normal life. With no other choice, he asks you, the smart one, for help.
Input Format
The first line contains two positive integers .
The next lines each contain two positive integers .
Output Format
Output a total of lines, each corresponding to Little A's answer for one round.
If it exists, output Yes; otherwise, output No.
9 3
1 4
2 1
7 4
No
Yes
Yes
29788562298698657 10
4623623705787050 4128735493476588
29371111781967946 19402395181570597
23313713550468151 18155134012955455
654639695903289 323875358727922
15727861955653242 26658913688488667
10815360622718474 4625834559167483
10836636083182170 10347869939717751
8972909638986721 1887397472131862
23442032136521081 29735793306181382
325363900801763 6960017105353559
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
No
Hint
Sample Explanation
.
.
.
Constraints
This problem has subtasks. You must pass all test points within a subtask to obtain the score for that subtask.
For all testdata, , , .
| # | Score | Special Property 1 | Time Limit | ||
|---|---|---|---|---|---|
| 1 | 3 | × | 1s | ||
| 2 | 37 | ||||
| 3 | 22 | ||||
| 4 | 13 | √ | |||
| 5 | 10 | × | |||
| 6 | 5 | ||||
| 7 | 10 | 3s |
Special Property 1: Let . Then is a prime chosen uniformly at random from .
Hint
You may use __int128.
Translated by ChatGPT 5
京公网安备 11011102002149号