1826C.md (2038B)
1 Source: https://codeforces.com/problemset/problem/1826/C 2 3 C. Dreaming of Freedom 4 5 time limit per test 6 7 2.5 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Because to take away a man's freedom of choice, even his freedom to make the wrong choice, is to manipulate him as though he were a puppet and not a person. 22 23 — Madeleine L'Engle 24 25 There are $n$ programmers choosing their favorite algorithm amongst $m$ different choice options. Before the first round, all $m$ options are available. In each round, every programmer makes a vote for one of the remaining algorithms. After the round, only the algorithms with the maximum number of votes remain. The voting process ends when there is only one option left. Determine whether the voting process can continue indefinitely or no matter how people vote, they will eventually choose a single option after some finite amount of rounds? 26 27 Input 28 29 The first line contains a single integer $t$ ($1 \leq t \leq 10^5$) — the number of test cases. 30 31 Each test case consists of a single line containing two integers $n$ and $m$ ($1 \leq n, m \leq 10^6$) — the number of people and choice options respectively. 32 33 Output 34 35 For each test case output "YES" if the programmers will eventually choose a single option, and "NO" otherwise. 36 37 You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as a positive answer). 38 39 Example 40 41 Input 42 43 ``` 44 5 45 46 3 2 47 48 4 2 49 50 5 3 51 52 1000000 1000000 53 54 1 1000000 55 ``` 56 57 Output 58 59 ``` 60 YES 61 NO 62 YES 63 NO 64 YES 65 ``` 66 67 Note 68 69 In the first example, there are $8$ ways people could vote: $\{1|1|1, 1|1|2, 1|2|1, 1|2|2, 2|1|1, 2|1|2, 2|2|1, 2|2|2\}$. 70 71 In cases $1$, $2$, $3$, and $5$, the programmers are left with the first algorithm, and in the remaining cases people are left with the second one, so the voting ends in one round in any case. 72 73 In the second example, the programmers could always vote $1|1|2|2$. Both algorithms have the maximum number of votes and remain for the next round, so the voting never ends.