結果

問題 No.2709 1975 Powers
ユーザー shobonvipshobonvip
提出日時 2024-04-01 01:34:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 164,504 KB
最終ジャッジ日時 2024-04-01 01:34:38
合計ジャッジ時間 6,379 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
124,112 KB
testcase_01 AC 88 ms
124,112 KB
testcase_02 AC 119 ms
135,284 KB
testcase_03 AC 155 ms
131,480 KB
testcase_04 AC 211 ms
147,340 KB
testcase_05 AC 188 ms
143,216 KB
testcase_06 AC 145 ms
140,120 KB
testcase_07 AC 100 ms
124,112 KB
testcase_08 AC 172 ms
159,256 KB
testcase_09 AC 178 ms
144,484 KB
testcase_10 AC 101 ms
124,112 KB
testcase_11 AC 126 ms
138,364 KB
testcase_12 AC 141 ms
147,332 KB
testcase_13 AC 242 ms
164,504 KB
testcase_14 AC 125 ms
132,884 KB
testcase_15 AC 141 ms
143,212 KB
testcase_16 AC 158 ms
138,464 KB
testcase_17 AC 113 ms
129,840 KB
testcase_18 AC 152 ms
154,200 KB
testcase_19 AC 218 ms
153,664 KB
testcase_20 AC 122 ms
135,648 KB
testcase_21 AC 171 ms
159,256 KB
testcase_22 AC 182 ms
143,924 KB
testcase_23 AC 214 ms
153,704 KB
testcase_24 AC 213 ms
146,040 KB
testcase_25 AC 198 ms
141,216 KB
testcase_26 AC 192 ms
139,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,p,q=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
mx=2000008
p10=[0]*mx
p09=[0]*mx
p07=[0]*mx
p05=[0]*mx
p10[0]=1
p09[0]=1
p07[0]=1
p05[0]=1
for i in range(1,mx):
	p10[i]=p10[i-1]*10%p
	p09[i]=p09[i-1]* 9%p
	p07[i]=p07[i-1]* 7%p
	p05[i]=p05[i-1]* 5%p

from collections import defaultdict
d=defaultdict(int)
ans=0
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			g=(p09[a[i]]+p07[a[j]]+p05[a[k]])%p
			#g+?=q
			#g+?=p+q
			ans+=d[p+q-g]+d[q-g]
	d[p10[a[i]]]+=1
print(ans)
0