CF621E.Wet Shark and Blocks

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

There are bb blocks of digits. Each one consisting of the same nn digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For example, if he chooses digit 11 from the first block and digit 22 from the second block, he gets the integer 1212 .

Wet Shark then takes this number modulo xx . Please, tell him how many ways he can choose one digit from each block so that he gets exactly kk as the final result. As this number may be too large, print it modulo 109+710^{9}+7 .

Note, that the number of ways to choose some digit in the block is equal to the number of it's occurrences. For example, there are 33 ways to choose digit 55 from block 3 5 6 7 8 9 5 1 1 1 1 5.

输入格式

The first line of the input contains four space-separated integers, nn , bb , kk and xx ( 2<=n<=50000,1<=b<=10^{9},0<=k<x<=100,x>=2 ) — the number of digits in one block, the number of blocks, interesting remainder modulo xx and modulo xx itself.

The next line contains nn space separated integers aia_{i} ( 1<=ai<=91<=a_{i}<=9 ), that give the digits contained in each block.

输出格式

Print the number of ways to pick exactly one digit from each blocks, such that the resulting integer equals kk modulo xx .

输入输出样例

  • 输入#1

    12 1 5 10
    3 5 6 7 8 9 5 1 1 1 1 5
    

    输出#1

    3
    
  • 输入#2

    3 2 1 2
    6 2 2
    

    输出#2

    0
    
  • 输入#3

    3 2 1 2
    3 1 2
    

    输出#3

    6
    

说明/提示

In the second sample possible integers are 2222 , 2626 , 6262 and 6666 . None of them gives the remainder 11 modulo 22 .

In the third sample integers 1111 , 1313 , 2121 , 2323 , 3131 and 3333 have remainder 11 modulo 22 . There is exactly one way to obtain each of these integers, so the total answer is 66 .

首页