-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe_numpy.py
More file actions
36 lines (27 loc) · 685 Bytes
/
e_numpy.py
File metadata and controls
36 lines (27 loc) · 685 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
def mul(A, B, b, p):
mod = 1000000007
res = np.zeros(b, dtype=np.int64)
BB = np.concatenate((B, B))
for i in range(b):
s = -i * p % b
res += A[i] * BB[s:s + b] % mod
return res % mod
def main():
n, b, _ = map(int, input().split())
c = np.array(list(map(int, input().split())))
res = np.zeros(b, dtype=np.int64)
res[0] = 1
p = 10
a = np.zeros(b, dtype=np.int64)
for i in c:
a[i % b] += 1
while n > 0:
if n % 2 == 1:
res = mul(res, a, b, p)
a = mul(a, a, b, p)
p = p * p % b
n //= 2
print(res[0])
if __name__ == "__main__":
main()