Skip to content

SIST-Manual/easy_Chthollys-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

easy_Chthollys-request

提交链接 / Submit

https://codeforces.com/problemset/problem/897/B

题目描述 / Description

- Thanks a lot for today.

- 感谢今天......

- I experienced so many great things.

- 我拥有了这么多美好的经历......

- You gave me memories like dreams... But I have to leave now...

- 你给了我梦幻般的记忆......但我不得不离开......

- One last request, can you...

- 最后一个请求, 你能......

- Help me solve a Codeforces problem?

- 帮助我解决一个Codeforces的问题吗?

- ......

- ......

- What?

- 什么?

Chtholly has been thinking about a problem for days:

珂朵莉已经思考一个问题很久了

If a number is palindrome and length of its decimal representation without leading zeros is even, we call it a zcy number. A number is palindrome means when written in decimal representation, it contains no leading zeros and reads the same forwards and backwards. For example 12321 and 1221 are palindromes and 123 and 12451 are not. Moreover, 1221 is zcy number and 12321 is not.

如果一个数是回文并且它没有前导零, 它的长度为偶数, 我们叫这样一个数为一个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

提示 / Note

In the first example, the smallest zcy number is 11, and the second smallest zcy number is 22.

In the second example, (11 + 22 + 33 + 44 + 55) mod 30 = 15

提示

在第一个样例里, 最小的zcy数是11, 第二小的是22

在第二个样例里, (11 + 22 + 33 + 44 + 55) mod 30 = 15

答案 / Solutions

Writeup

Python

Cpp

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published