結果

問題 No.2709 1975 Powers
ユーザー Basin-Bug
提出日時 2024-03-31 14:38:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 921 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 24,740 KB
最終ジャッジ日時 2024-09-30 19:46:24
合計ジャッジ時間 3,624 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

N, P, Q = map(int, input().split())
A = list(map(int, input().split()))

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)  
    
    # currentをリセット
    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 + a) % P] += previous[0][j]
        current[1][j] += previous[1][j]
        current[2][(j + b) % P] += previous[1][j]
        current[2][j] += previous[2][j]
        current[3][(j + c) % P] += previous[2][j]
        current[3][j] += previous[3][j]
        current[4][(j + d) % P] += previous[3][j]  
        current[4][j] += previous[4][j]
    
    previous, current = current, previous
print(previous[4][Q])
0