| HPI 2024 Novice |
|---|
| Finished |
Lazy Bob lives in Bobland, a country with $$$N$$$ ($$$2 ≤ N ≤ 100,000$$$) cities, each labeled with a number from $$$0…N-1$$$. Each city $$$x$$$ has a one way road to exactly one other city: $$$2x$$$ (mod $$$N$$$).
Lazy Bob is standing at city $$$K$$$ ($$$0 ≤ K ≤ N-1$$$). A self-driving car starts at city $$$1$$$ and keeps driving on one way roads, keeping a running sum of the labels of all the cities it goes through (including city $$$1$$$). However, because this running sum can be very big, it displays the remainder when this sum is divided by $$$N+1$$$.
Bob is curious to know if he will, at some point, see every value from $$$0$$$ to $$$N$$$ on the autonomous car's display. Help Bob by printing "YES" if this is the case, and "NO" otherwise (without the quotes). Because Bob is lazy (it is part of his name, after all), he will permanently stay in city $$$K$$$.
Line 1: Two space-separated integers, $$$N$$$ and $$$K$$$ ($$$2 ≤ N ≤ 100,000$$$, $$$0 ≤ K ≤ N-1$$$).
Line 1: "YES" if Bob will at some point see every value from $$$0$$$ to $$$N$$$ on the self-driving car's display, and "NO" otherwise (without the quotation marks)
3 1
YES
Here are the first 8 value-city states that the car will reach, with the value displayed (mod $$$N+1$$$), as it is on the car:
1: value: 1 city: 1
2: value: 3 city: 2
3: value: 0 city: 1
4: value: 2 city: 2
5: value: 3 city: 1
6: value: 1 city: 2
7: value: 2 city: 1
8: value: 0 city: 2
Bob is at city 1, and he will see value 0 at step 3, value 1 at step 1, value 2 at step 7, and value 3 at step 5. These are all of the possible values, (mod $$$N+1$$$), so the answer is "YES".
| Name |
|---|


