結果

問題 No.2709 1975 Powers
ユーザー 👑 timitimi
提出日時 2024-03-31 14:08:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 82,120 KB
最終ジャッジ日時 2024-03-31 14:08:53
合計ジャッジ時間 3,165 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 51 ms
64,464 KB
testcase_03 AC 81 ms
68,596 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 36 ms
53,460 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 36 ms
53,460 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 70 ms
68,732 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 52 ms
64,580 KB
testcase_21 WA -
testcase_22 AC 93 ms
71,744 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 101 ms
74,476 KB
testcase_26 AC 99 ms
73,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,P,Q=map(int, input().split())
A=list(map(int, input().split()))
A=sorted(A) 
ans=0
D,E={},{}
  
for i in range(N-1):
  for j in range(i+1,N):
    a=pow(10,A[i],P)
    b=pow(9,A[j],P)
    ab=(a+b)%P
    c=pow(7,A[i],P)
    d=pow(5,A[j],P)
    cd=(c+d)%P
    if ab not in D:
      D[ab]=[]
    D[ab].append(j)
    if cd not in E:
      E[cd]=[]
    E[cd].append(i)
    

for e in E:
  E[e]=sorted(E[e])
  
import bisect
for d in D:
  q=Q-d 
  if q in E:
    for now in D[d]:
      c=bisect.bisect_right(E[q],now)
      ans+=len(E[q])-c 
  q=2*Q-d 
  if q in E:
    for now in D[d]:
      c=bisect.bisect_right(E[q],now)
      ans+=len(E[q])-c 
print(ans)
0