結果

問題 No.2709 1975 Powers
ユーザー nikoro256nikoro256
提出日時 2024-03-31 14:14:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 401 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 251,148 KB
最終ジャッジ日時 2024-03-31 14:14:28
合計ジャッジ時間 9,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,604 KB
testcase_01 AC 42 ms
55,604 KB
testcase_02 AC 387 ms
248,660 KB
testcase_03 AC 342 ms
248,932 KB
testcase_04 AC 365 ms
248,860 KB
testcase_05 AC 375 ms
251,096 KB
testcase_06 AC 333 ms
251,012 KB
testcase_07 AC 308 ms
249,660 KB
testcase_08 AC 349 ms
251,148 KB
testcase_09 AC 378 ms
250,948 KB
testcase_10 AC 315 ms
246,416 KB
testcase_11 AC 312 ms
249,852 KB
testcase_12 AC 325 ms
251,132 KB
testcase_13 AC 401 ms
251,124 KB
testcase_14 AC 332 ms
250,684 KB
testcase_15 AC 335 ms
250,604 KB
testcase_16 AC 359 ms
246,416 KB
testcase_17 AC 334 ms
251,060 KB
testcase_18 AC 328 ms
251,044 KB
testcase_19 AC 375 ms
251,060 KB
testcase_20 AC 317 ms
249,756 KB
testcase_21 AC 359 ms
250,500 KB
testcase_22 AC 369 ms
246,416 KB
testcase_23 AC 399 ms
246,416 KB
testcase_24 AC 395 ms
246,416 KB
testcase_25 AC 357 ms
246,416 KB
testcase_26 AC 400 ms
246,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def makeexp(n):
    re=[1]
    for i in range(ma+2):
        re.append(re[-1]*n%P)
    return re

from collections import defaultdict
N,P,Q=map(int,input().split())
A=list(map(int,input().split()))
A=list(set(A))
A=sorted(A)
rightdic=defaultdict(int)
ma=max(A)
exp10=makeexp(10)
exp9=makeexp(9)
exp7=makeexp(7)
exp5=makeexp(5)
N=len(A)
for i in range(N):
    rightdic[exp5[A[i]]]+=1
ans=0
for i in range(N):
    #iを3番目とする。
    rightdic[exp5[A[i]]]-=1
    if i<2:
        continue
    for j in range(i):
        for k in range(j+1,i):
            left=(exp10[A[j]]+exp9[A[k]]+exp7[A[i]])%P
            ans+=rightdic[(Q-left)%P]
print(ans)
0