No.3535 $E\times - Otogibanashi$
タグ : / 解いたユーザー数 70
作問者 :
nauclhlt
/ テスター :
Problem Statement
A positive integer satisfying the following condition is called an Otogibanashi number.
- In its $10$-based decimal notation (without extra leading $0$), it has $6$ digits, and, writing $d_i$ for the digit in the $10^i$ place, all of $d_5=d_4, d_3=d_0, d_2=d_1$ hold
For example, 112332 and 555555 are Otogibanashi numbers, but 110101 and 120 are not Otogibanashi numbers.
Furthermore, an integer satisfying the following condition is called an Ex Otogibanashi number.
- There exist an Otogibanashi number $k$ and a positive integer $E$ such that it can be expressed as $E\times (-k)$
You are given a positive integer $N$ and a prime $P$. Find the sum of all Ex Otogibanashi numbers whose absolute value is at most $N$, modulo $P$, as a value at least $0$ and less than $P$.
Input
$N\ P$
- $1\leq N\leq 10^9$
- $10^8\leq P< 10^9$
- $P$ is prime
- All inputs are integers
Output
Print on one line the sum of all Ex Otogibanashi numbers whose absolute value is at most $N$, modulo $P$.
Print a newline at the end.
Sample
Sample 1
Input
1729 998244353
Output
0
There are no Ex Otogibanashi numbers whose absolute value is at most $1729$. The sum is therefore $0$ as well, so print 0.
Sample 2
Input
998244353 998244353
Output
910462579
Note that you must print the remainder when divided by the prime $P$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。