CF520E.Pluses everywhere

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses ("+") in the line between certain digits in the line so that the result was a correct arithmetic expression; formally, no two pluses in such a partition can stand together (between any two adjacent pluses there must be at least one digit), and no plus can stand at the beginning or the end of a line. For example, in the string 100500, ways 100500 (add no pluses), 1+00+500 or 10050+0 are correct, and ways 100++500, +1+0+0+5+0+0 or 100500+ are incorrect.

The lesson was long, and Vasya has written all the correct ways to place exactly k pluses in a string of digits. At this point, he got caught having fun by a teacher and he was given the task to calculate the sum of all the resulting arithmetic expressions by the end of the lesson (when calculating the value of an expression the leading zeros should be ignored). As the answer can be large, Vasya is allowed to get only its remainder modulo 109 + 7. Help him!

瓦西娅正坐在一节极其枯燥的数学课上。为了找点乐子,他拿出一张纸,在一行中写下了 nn 个数字。接着,瓦西娅开始在这些数字之间以不同方式插入加号(“+”),使得结果构成一个合法的算术表达式;形式化地说,这样的插入方案中任意两个加号不能相邻(即任意两个相邻加号之间至少要有一个数字),且加号不能出现在字符串开头或结尾。例如,在字符串 100500 中,方案 100500(不插入任何加号)、1+00+500 和 10050+0 是合法的;而 100++500、+1+0+0+5+0+0 和 100500+ 则是非法的。

这节课很长,瓦西娅已将恰好插入 kk 个加号的所有合法方案全部写出。此时,他因玩耍被老师发现,并被布置了一项任务:在下课前计算所有这些算术表达式求值结果的总和(计算表达式值时,应忽略前导零)。由于答案可能很大,瓦西娅只需给出该总和对 109+710^9 + 7 取模的结果。请帮助他!

输入格式

The first line contains two integers, n and k (0 ≤ k < n ≤ 105).

The second line contains a string consisting of n digits.

第一行包含两个整数 nn 和 kk(0 ≤ k < n ≤ 1050 \le k < n \le 10^5)。

第二行包含一个由 nn 个数字组成的字符串。

输出格式

Print the answer to the problem modulo 109 + 7.

将问题的答案对 109+710^9 + 7 取模后输出。

输入输出样例

  • 输入#1

    3 1
    108

    输出#1

    27
  • 输入#2

    3 2
    108

    输出#2

    9

说明/提示

In the first sample the result equals (1 + 08) + (10 + 8) = 27.

In the second sample the result equals 1 + 0 + 8 = 9.

在第一个样例中,结果等于 (1 + 08) + (10 + 8) = 27(1 + 08) + (10 + 8) = 27。

在第二个样例中,结果等于 1 + 0 + 8 = 91 + 0 + 8 = 9。

输入解题思路,AI测评打分。不知道怎么写?

首页