結果
| 問題 | No.2709 1975 Powers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-03-31 14:47:07 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,017 ms / 2,000 ms | 
| コード長 | 840 bytes | 
| コンパイル時間 | 499 ms | 
| コンパイル使用メモリ | 82,040 KB | 
| 実行使用メモリ | 77,568 KB | 
| 最終ジャッジ日時 | 2024-10-01 03:17:53 | 
| 合計ジャッジ時間 | 13,746 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 25 | 
ソースコード
N, P, Q = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
current = [[0] * P for i in range(5)]
previous = [[0] * P for i in range(5)]
previous[0][0] = 1  
for i in range(1, N + 1):
  a = pow(10, A[i - 1], P)
  b = pow(9, A[i - 1], P)
  c = pow(7, A[i - 1], P)
  d = pow(5, A[i - 1], P)  
    
  for j in range(5):
    for k in range(P):
      current[j][k] = 0
  for j in range(P):
    current[0][j] += previous[0][j]
    current[1][j] += previous[1][j]
    current[2][j] += previous[2][j]
    current[3][j] += previous[3][j]
    current[4][j] += previous[4][j]
    current[1][(j + a) % P] += previous[0][j]
    current[2][(j + b) % P] += previous[1][j]
    current[3][(j + c) % P] += previous[2][j]
    current[4][(j + d) % P] += previous[3][j]  
  previous, current = current, previous
print(previous[4][Q])
            
            
            
        