結果

問題 No.2709 1975 Powers
ユーザー ButterflvButterflv
提出日時 2024-04-18 10:26:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 157,540 KB
最終ジャッジ日時 2024-04-18 10:26:37
合計ジャッジ時間 26,491 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
60,160 KB
testcase_01 AC 45 ms
60,288 KB
testcase_02 AC 108 ms
71,808 KB
testcase_03 AC 1,205 ms
78,104 KB
testcase_04 AC 1,925 ms
129,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 63 ms
61,184 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 47 ms
61,144 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 357 ms
77,488 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,949 ms
78,112 KB
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)
      target=(Q-v)%P
      ans+=stset[c+1][target]
print(ans)
0