409013: GYM103415 E Mathlab

Memory Limit:512 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Mathlabtime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

The function $$$f(x)$$$ is defined as the sum of all digits of $$$x$$$ in hexadecimal. Given an $$$n$$$-digit hexadecimal number $$$x$$$ and an index $$$k$$$, calculate $$$$$$\sum \limits_{i=0}^{x-1} f((16^k-1) \cdot i) \bmod 2^{64}.$$$$$$

Input

The first line contains two positive integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 100$$$ and $$$5k \ge n$$$).

The second line contains a string of length $$$n$$$ — the value of given $$$x$$$ in hexadecimal.

The string only consists of decimal digits and 'A','B','C','D','E','F'. Also the first digit is not '0'.

Output

The only line contains an integer — the answer.

ExampleInput
4 1
7FFF
Output
1081320

加入题单

算法标签: