Wet Shark and Blocks

题意翻译

题目描述: 有 $b$ 个格子,每个格子有 $n$ 个数字,各个格子里面的数字都是相同的. 求从 $b$ 个格子中各取一个数字, 构成一个 $b$ 位数, 使得这个 $b$ 位数模 $x$ 为 $k$ 的方案数(同一格子内相同的数字算不同方案).答案对 $1\times 10^9+7$ 取模. 输入格式: 第一行有4个整数 $n,b,k,x$ ,其中 $2\leq n\leq 50000,1\leq b\leq 10^{9},0\leq k< x\leq 100,x\ge2$ 第二行有 $n$ 个数, 为每个格子里面的数字(每个格子里面的数字都是相同的.) 输出格式: 即从每个块中选择一个数构成一个大数, 使得其模x为k的方案数对 $1\times 10^9+7$ 取模. 注意: 样例二中没有一种方案使得模2为1 样例三中11,13,21,23,31,33满足模2余1. 感谢@aiyougege 提供的翻译

题目描述

There are $ b $ blocks of digits. Each one consisting of the same $ n $ 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 $ 1 $ from the first block and digit $ 2 $ from the second block, he gets the integer $ 12 $ . Wet Shark then takes this number modulo $ x $ . Please, tell him how many ways he can choose one digit from each block so that he gets exactly $ k $ as the final result. As this number may be too large, print it modulo $ 10^{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 $ 3 $ ways to choose digit $ 5 $ 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, $ n $ , $ b $ , $ k $ and $ x $ ( $ 2<=n<=50000,1<=b<=10^{9},0<=k&lt;x<=100,x>=2 $ ) — the number of digits in one block, the number of blocks, interesting remainder modulo $ x $ and modulo $ x $ itself. The next line contains $ n $ space separated integers $ a_{i} $ ( $ 1<=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 $ k $ modulo $ x $ .

输入输出样例

输入样例 #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 $ 22 $ , $ 26 $ , $ 62 $ and $ 66 $ . None of them gives the remainder $ 1 $ modulo $ 2 $ . In the third sample integers $ 11 $ , $ 13 $ , $ 21 $ , $ 23 $ , $ 31 $ and $ 33 $ have remainder $ 1 $ modulo $ 2 $ . There is exactly one way to obtain each of these integers, so the total answer is $ 6 $ .