Codeforces Round 191 (Div. 2)
C
Magic Five
Codeforces
1700
原题
← BD →
翻译中…

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.

翻译中…

Input

翻译中…

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*$.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

In the first case, there are four possible ways to make a number that is divisible by 5: 5, 15, 25 and 125.

翻译中…

In the second case, remember to concatenate the copies of $*a*$. The actual plate is 1399013990.

翻译中…

In the third case, except deleting all digits, any choice will do. Therefore there are $2^{6} - 1 = 63$ possible ways to delete digits.

翻译中…

样例

Input #1
1256
1
Output #1
4
InputCopy OutputCopy
Input #2
13990
2
Output #2
528
InputCopy OutputCopy
Input #3
555
2
Output #3
63
InputCopy OutputCopy
题目信息
题号
327C
时间限制
1 s
内存限制
256 MB
标签
组合数学
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。