結果

問題 No.2709 1975 Powers
ユーザー Basin-BugBasin-Bug
提出日時 2024-03-31 14:10:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 676 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 225,556 KB
最終ジャッジ日時 2024-03-31 14:10:08
合計ジャッジ時間 3,540 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
16,916 KB
testcase_01 AC 27 ms
10,112 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [[[0] * P for i in range(5)] for j in range(N + 1)]
dp[0][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(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]
    dp[i][4][(j + d) % P] += dp[i - 1][3][j]
    dp[i][4][j] += dp[i - 1][4][j]

print(dp[-1][-1][Q])
0