結果

問題 No.551 夏休みの思い出(2)
ユーザー pekempeypekempey
提出日時 2017-07-29 04:05:22
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 338 ms / 4,000 ms
コード長 442 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 80,972 KB
最終ジャッジ日時 2023-08-01 04:47:35
合計ジャッジ時間 12,045 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,100 KB
testcase_01 AC 75 ms
71,504 KB
testcase_02 AC 82 ms
71,200 KB
testcase_03 AC 133 ms
77,724 KB
testcase_04 AC 156 ms
78,312 KB
testcase_05 AC 195 ms
78,760 KB
testcase_06 AC 214 ms
79,792 KB
testcase_07 AC 75 ms
71,452 KB
testcase_08 AC 74 ms
71,308 KB
testcase_09 AC 76 ms
71,300 KB
testcase_10 AC 75 ms
71,356 KB
testcase_11 AC 75 ms
71,292 KB
testcase_12 AC 75 ms
71,424 KB
testcase_13 AC 75 ms
71,260 KB
testcase_14 AC 76 ms
71,484 KB
testcase_15 AC 75 ms
71,256 KB
testcase_16 AC 75 ms
71,208 KB
testcase_17 AC 85 ms
76,152 KB
testcase_18 AC 85 ms
76,112 KB
testcase_19 AC 83 ms
76,128 KB
testcase_20 AC 86 ms
76,152 KB
testcase_21 AC 85 ms
76,184 KB
testcase_22 AC 87 ms
76,172 KB
testcase_23 AC 84 ms
76,240 KB
testcase_24 AC 84 ms
76,156 KB
testcase_25 AC 82 ms
76,144 KB
testcase_26 AC 85 ms
76,028 KB
testcase_27 AC 323 ms
80,888 KB
testcase_28 AC 315 ms
80,676 KB
testcase_29 AC 301 ms
80,492 KB
testcase_30 AC 321 ms
80,392 KB
testcase_31 AC 294 ms
80,628 KB
testcase_32 AC 313 ms
80,636 KB
testcase_33 AC 320 ms
80,576 KB
testcase_34 AC 312 ms
80,844 KB
testcase_35 AC 313 ms
80,168 KB
testcase_36 AC 317 ms
80,336 KB
testcase_37 AC 338 ms
79,296 KB
testcase_38 AC 331 ms
80,348 KB
testcase_39 AC 319 ms
80,164 KB
testcase_40 AC 324 ms
80,552 KB
testcase_41 AC 316 ms
80,512 KB
testcase_42 AC 334 ms
80,972 KB
testcase_43 AC 328 ms
80,848 KB
testcase_44 AC 309 ms
79,712 KB
testcase_45 AC 302 ms
80,132 KB
testcase_46 AC 323 ms
79,128 KB
testcase_47 AC 71 ms
71,488 KB
testcase_48 AC 72 ms
71,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p,_=map(int,input().split())
f=lambda a:pow(a,p-1>>1,p)!=p-1
def h(a):
	if a%p==0:return 0
	b=2
	while f(b*b-a):b+=1
	h=lambda u,v:((u[0]*v[0]+u[1]*v[1]*(b*b-a))%p,(u[0]*v[1]+u[1]*v[0])%p)
	e=p+1>>1
	r=1,0
	v=b,1
	while e:
		if e&1:r=h(r,v)
		v=h(v,v)
		e>>=1
	return r[0]
for _ in range(int(input())):
	a,b,c=map(int,input().split())
	d=b*b-4*a*c
	a=pow(2*a,p-2,p)
	D=h(d)
	if f(d):print(*sorted(set(((D-b)*a%p,(-b-D)*a%p))))
	else:print(-1)
0