結果

問題 No.551 夏休みの思い出(2)
ユーザー pekempeypekempey
提出日時 2017-07-29 04:05:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 312 ms / 4,000 ms
コード長 442 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 80,100 KB
最終ジャッジ日時 2024-04-19 04:29:14
合計ジャッジ時間 9,103 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,712 KB
testcase_01 AC 39 ms
53,164 KB
testcase_02 AC 48 ms
55,984 KB
testcase_03 AC 98 ms
76,684 KB
testcase_04 AC 121 ms
77,196 KB
testcase_05 AC 160 ms
77,428 KB
testcase_06 AC 175 ms
77,832 KB
testcase_07 AC 41 ms
53,944 KB
testcase_08 AC 43 ms
54,604 KB
testcase_09 AC 45 ms
54,728 KB
testcase_10 AC 43 ms
54,236 KB
testcase_11 AC 42 ms
54,596 KB
testcase_12 AC 42 ms
54,612 KB
testcase_13 AC 40 ms
53,532 KB
testcase_14 AC 41 ms
54,132 KB
testcase_15 AC 44 ms
55,176 KB
testcase_16 AC 41 ms
54,368 KB
testcase_17 AC 51 ms
64,356 KB
testcase_18 AC 51 ms
65,032 KB
testcase_19 AC 49 ms
61,996 KB
testcase_20 AC 51 ms
64,252 KB
testcase_21 AC 52 ms
64,900 KB
testcase_22 AC 49 ms
63,636 KB
testcase_23 AC 53 ms
63,212 KB
testcase_24 AC 51 ms
63,136 KB
testcase_25 AC 48 ms
63,892 KB
testcase_26 AC 50 ms
64,708 KB
testcase_27 AC 282 ms
78,972 KB
testcase_28 AC 278 ms
78,696 KB
testcase_29 AC 271 ms
79,324 KB
testcase_30 AC 288 ms
78,496 KB
testcase_31 AC 268 ms
78,264 KB
testcase_32 AC 278 ms
80,100 KB
testcase_33 AC 274 ms
79,400 KB
testcase_34 AC 282 ms
79,532 KB
testcase_35 AC 270 ms
79,260 KB
testcase_36 AC 279 ms
78,752 KB
testcase_37 AC 312 ms
79,016 KB
testcase_38 AC 298 ms
79,912 KB
testcase_39 AC 288 ms
79,620 KB
testcase_40 AC 290 ms
79,348 KB
testcase_41 AC 272 ms
79,148 KB
testcase_42 AC 303 ms
79,436 KB
testcase_43 AC 302 ms
79,088 KB
testcase_44 AC 271 ms
78,960 KB
testcase_45 AC 266 ms
79,856 KB
testcase_46 AC 293 ms
79,600 KB
testcase_47 AC 37 ms
51,940 KB
testcase_48 AC 38 ms
52,372 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