結果

問題 No.2709 1975 Powers
ユーザー ButterflvButterflv
提出日時 2024-04-18 10:22:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 575 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 158,344 KB
最終ジャッジ日時 2024-04-18 10:23:24
合計ジャッジ時間 26,992 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
61,476 KB
testcase_01 AC 47 ms
61,048 KB
testcase_02 AC 112 ms
72,256 KB
testcase_03 AC 1,124 ms
78,016 KB
testcase_04 AC 1,875 ms
129,360 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 51 ms
62,164 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 48 ms
63,016 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 372 ms
77,460 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import copy
N, P, Q=map(int, input().split())
A=list(map(int, input().split()))
stset=[None for i in range(N)]
for i in range(len(A)-1, -1, -1):
  if i==len(A)-1:
    obj=defaultdict(int)
    obj[pow(5, A[i], P)]+=1
    stset[i]=obj
    continue
  obj=copy.deepcopy(stset[i+1])
  obj[pow(5, A[i], P)]+=1
  stset[i]=obj
ans=0
for a in range(N-4+1):
  for b in range(a+1, N-3+1):
    for c in range(b+1, N-2+1):
      v=pow(10, A[a], P)+pow(9, A[b], P)+pow(7, A[c], P)
      v%=P
      target=(Q-v)%P
      ans+=stset[c+1][target]
print(ans)
0