結果

問題 No.2709 1975 Powers
ユーザー Basin-BugBasin-Bug
提出日時 2024-03-31 14:38:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,316 KB
最終ジャッジ日時 2024-03-31 14:39:00
合計ジャッジ時間 15,315 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,460 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 383 ms
78,316 KB
testcase_03 AC 528 ms
71,004 KB
testcase_04 AC 879 ms
73,084 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 145 ms
73,100 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 147 ms
73,220 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 310 ms
70,464 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1,145 ms
73,964 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 811 ms
72,284 KB
testcase_26 AC 954 ms
72,964 KB
権限があれば一括ダウンロードができます

ソースコード

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