結果

問題 No.2709 1975 Powers
ユーザー Basin-BugBasin-Bug
提出日時 2024-03-31 14:28:42
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 667 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 631,104 KB
最終ジャッジ日時 2024-03-31 14:29:06
合計ジャッジ時間 23,339 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 533 ms
235,704 KB
testcase_03 AC 833 ms
341,872 KB
testcase_04 MLE -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 189 ms
114,508 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 196 ms
118,108 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 MLE -
testcase_14 AC 478 ms
219,036 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 WA -
testcase_25 AC 1,282 ms
495,884 KB
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [[[0] * P for i in range(4)] for j in range(N + 1)]
dp[0][0][0] = 1

p = [pow(5, A[i], P) for i in range(N)]

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)

  for j in range(P):
    dp[i][0][j] += dp[i - 1][0][j]
    dp[i][1][(j + a) % P] += dp[i - 1][0][j]
    dp[i][1][j] += dp[i - 1][1][j]
    dp[i][2][(j + b) % P] += dp[i - 1][1][j]
    dp[i][2][j] += dp[i - 1][2][j]
    dp[i][3][(j + c) % P] += dp[i - 1][2][j]
    dp[i][3][j] += dp[i - 1][3][j]

ans = 0
for i in range(3, N):
  ans += dp[i][-1][(Q - p[i]) % P]

print(ans)
0