結果

問題 No.2709 1975 Powers
ユーザー prd_xxxprd_xxx
提出日時 2024-03-31 14:04:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 644 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 330,740 KB
最終ジャッジ日時 2024-03-31 14:04:23
合計ジャッジ時間 22,119 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 60 ms
75,548 KB
testcase_03 AC 201 ms
87,092 KB
testcase_04 AC 1,131 ms
228,068 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 45 ms
62,108 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 47 ms
62,108 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 AC 336 ms
116,020 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 TLE -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 446 ms
131,100 KB
testcase_23 TLE -
testcase_24 WA -
testcase_25 AC 887 ms
173,748 KB
testcase_26 AC 385 ms
103,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


Z = [10,9,7,5]
pw = [[pow(z,a,P) for a in A] for z in Z]

dp = [{} for _ in range(5)]
dp[0] = {0:1}
for i in range(N):
    ndp = [{} for _ in range(5)]
    for j in range(5):
        for k,v in dp[j].items():
            if k in ndp[j]:
                ndp[j][k] += v
            else:
                ndp[j][k] = v
            if j==4: break
            nk = (k + pw[j][i]) % P
            if nk in ndp[j+1]:
                ndp[j+1][nk] += v
            else:
                ndp[j+1][nk] = v
    dp = ndp

if Q in dp[-1]:
    print(dp[-1][Q])
else:
    print(0)
0