897B.md (1549B)
1 Source: https://codeforces.com/problemset/problem/897/B 2 3 B. Chtholly's request 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 — Thanks a lot for today. 22 23 — I experienced so many great things. 24 25 — You gave me memories like dreams... But I have to leave now... 26 27 — One last request, can you... 28 29 — Help me solve a Codeforces problem? 30 31 — ...... 32 33 — What? 34 35 Chtholly has been thinking about a problem for days: 36 37 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. 38 39 Given integers *k* and *p*, calculate the sum of the *k* smallest zcy numbers and output this sum modulo *p*. 40 41 Unfortunately, Willem isn't good at solving this kind of problems, so he asks you for help! 42 43 Input 44 45 The first line contains two integers *k* and *p* (1 ≤ *k* ≤ 105, 1 ≤ *p* ≤ 109). 46 47 Output 48 49 Output single integer — answer to the problem. 50 51 Examples 52 53 Input 54 55 ``` 56 2 100 57 ``` 58 59 Output 60 61 ``` 62 33 63 ``` 64 65 Input 66 67 ``` 68 5 30 69 ``` 70 71 Output 72 73 ``` 74 15 75 ``` 76 77 Note 78 79 In the first example, the smallest zcy number is 11, and the second smallest zcy number is 22. 80 81 In the second example, .