結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 52 ms
64,464 KB
testcase_03 AC 84 ms
68,596 KB
testcase_04 AC 101 ms
75,248 KB
testcase_05 AC 112 ms
77,480 KB
testcase_06 AC 94 ms
77,880 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 80 ms
72,884 KB
testcase_09 AC 117 ms
78,840 KB
testcase_10 AC 37 ms
53,460 KB
testcase_11 AC 63 ms
68,660 KB
testcase_12 AC 64 ms
68,628 KB
testcase_13 AC 120 ms
81,052 KB
testcase_14 AC 70 ms
68,732 KB
testcase_15 AC 72 ms
68,616 KB
testcase_16 AC 121 ms
79,008 KB
testcase_17 AC 41 ms
53,460 KB
testcase_18 AC 64 ms
68,732 KB
testcase_19 AC 130 ms
81,484 KB
testcase_20 AC 58 ms
64,580 KB
testcase_21 AC 81 ms
72,880 KB
testcase_22 AC 95 ms
71,744 KB
testcase_23 AC 129 ms
82,120 KB
testcase_24 AC 132 ms
81,868 KB
testcase_25 AC 103 ms
74,476 KB
testcase_26 AC 102 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=P+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