CF327C.Magic Five

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

There is a long plate ss containing nn 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 55 . Note that, the resulting number may contain leading zeros.

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

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

输入格式

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

输出格式

Print a single integer — the required number of ways modulo 10000000071000000007 ( 109+710^{9}+7 ).

输入输出样例

  • 输入#1

    1256
    1
    

    输出#1

    4
    
  • 输入#2

    13990
    2
    

    输出#2

    528
    
  • 输入#3

    555
    2
    

    输出#3

    63
    

说明/提示

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 aa . The actual plate is 1399013990.

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

首页