Divisibility in a Strange System
Limits: 2 sec., 512 MiB
This statement was translated automatically from Ukrainian.
Teenage Mutant Ninja Turtles are not very skilled at working with an unusual number system.
They want to know if the number \(n\) is divisible by \(m - 1\). However, the number \(n\) is given in a number system with base \(m\), and they do not know what to do with this.
Help them determine whether \(n\) is divisible by \(m - 1\).
Input
The first line contains an integer \(m\) — the base of the number system.
The second line contains an integer \(n\) in the number system with base \(m\).
Output
In a single line, print Yes if \(n\) is divisible by \(m - 1\), or No otherwise.
Constraints
\(2 \le m \le 10\),
\(0 \le n \le 10^{10^6}\),
\(0 \le n_i < m\), where \(n_i\) is the \(i\)-th digit of the number \(n\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 10 81 | Yes |
| Input (stdin) | Output (stdout) |
|---|---|
| 10 4774 | No |
| Input (stdin) | Output (stdout) |
|---|---|
| 2 101111 | Yes |
| Input (stdin) | Output (stdout) |
|---|---|
| 7 44441234560000044044046543214444 | No |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|