题库练习 Magic Five
← 上一题 下一题 →

A9147 | Magic Five

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

There is a long plate $s$ containing $n$ digits. Iahub wants to delete some digits (possibly none, but he is not allowed to delete all the digits) to form his "magic number" on the plate, a number that is divisible by $5$ . Note that, the resulting number may contain leading zeros.

Now Iahub wants to count the number of ways he can obtain magic number, modulo $1000000007$ ( $10^{9}+7$ ). Two ways are different, if the set of deleted positions in $s$ differs.

Look at the input part of the statement, $s$ is given in a special form.

输入格式

In the first line you're given a string $a$ ( $1<=|a|<=10^{5}$ ), containing digits only. In the second line you're given an integer $k$ ( $1<=k<=10^{9}$ ). The plate $s$ is formed by concatenating $k$ copies of $a$ together. That is $n=|a|·k$ .

输出格式

Print a single integer — the required number of ways modulo $1000000007$ ( $10^{9}+7$ ).

输入输出样例

输入 #1
1256
1
输出 #1
4
输入 #2
13990
2
输出 #2
528
输入 #3
555
2
输出 #3
63
C++ 编辑器
输入
输出