Problem H
Number Magic
Alice and Bob engage in a strategic duel called Number
Magic, where Alice initially chooses a positive integer
-
Say
has digits. One operation is to add the number consisting of -digits (i.e. ) to . For example, if then this magic operation would add to resulting in ; if then it becomes ; if it becomes . -
If
, one operation is to divide by and round down. For example, if then it becomes , if it becomes .
There are
This is a very challenging game, Alice has asked you for help!
Input
The first line of input contains two space integers,
Then
Output
Output
Sample Input 1 | Sample Output 1 |
---|---|
7 2 43 28 |
YES YES |
Sample Input 2 | Sample Output 2 |
---|---|
74 1 18 |
YES |
Sample Input 3 | Sample Output 3 |
---|---|
22 2 9961 1 |
NO YES |