如果一个数是回文并且它没有前导零, 它的长度为偶数, 我们叫这样一个数为一个zcy数。当一个数是回文, 这个数没有前导零并且反着读和它本身一样。例如, 12321和1221是回文, 123和12451不是回文。此外, 1221是zcy数, 12321不是。
Given integers k and p, calculate the sum of the k smallest zcy numbers and output this sum modulo p.
给出整数k和p, 计算前k大的zcy数的和, 输出这个和对p取余的结果。
Unfortunately, Willem isn’t good at solving this kind of problems, so he asks you for help!
不幸的是, 威廉不擅长解决这种问题, 因此他请你帮忙。
输入 / Input
The first line contains two integers k and p (1 ≤ k ≤ 105, 1 ≤ p ≤ 109).
第一行包括两个整数k和p (1 ≤ k ≤ 105, 1 ≤ p ≤ 109).
输出 / Output
Output single integer \— answer to the problem.
输出一个整数 - 问题的答案.
样例 / Example
input1
2 100
output1
33
input2
5 30
output2
15
k, p = map(int, input().split())
res = 0
#解法1
for i in range(1, k+1):
res += int(str(i)+str(i)[::-1])
print(res % p)
#解法2
a = [11,22,33,44,55,66,77,88,99]
s = 0
for i in range(k):
s+=a[i]
print(s%p)