結果

問題 No.551 夏休みの思い出(2)
ユーザー pekempeypekempey
提出日時 2017-07-29 03:25:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 333 ms / 4,000 ms
コード長 498 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 79,624 KB
最終ジャッジ日時 2024-04-19 04:01:01
合計ジャッジ時間 10,252 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
51,840 KB
testcase_01 AC 49 ms
53,120 KB
testcase_02 AC 57 ms
54,784 KB
testcase_03 AC 124 ms
76,800 KB
testcase_04 AC 131 ms
77,056 KB
testcase_05 AC 185 ms
77,056 KB
testcase_06 AC 206 ms
77,964 KB
testcase_07 AC 45 ms
53,248 KB
testcase_08 AC 51 ms
53,248 KB
testcase_09 AC 49 ms
53,248 KB
testcase_10 AC 50 ms
53,504 KB
testcase_11 AC 51 ms
53,376 KB
testcase_12 AC 49 ms
53,120 KB
testcase_13 AC 51 ms
53,504 KB
testcase_14 AC 49 ms
52,864 KB
testcase_15 AC 49 ms
53,504 KB
testcase_16 AC 50 ms
52,864 KB
testcase_17 AC 61 ms
63,104 KB
testcase_18 AC 71 ms
63,232 KB
testcase_19 AC 65 ms
61,440 KB
testcase_20 AC 61 ms
63,104 KB
testcase_21 AC 60 ms
63,232 KB
testcase_22 AC 63 ms
62,592 KB
testcase_23 AC 64 ms
62,848 KB
testcase_24 AC 56 ms
62,720 KB
testcase_25 AC 59 ms
61,952 KB
testcase_26 AC 61 ms
62,976 KB
testcase_27 AC 303 ms
78,636 KB
testcase_28 AC 305 ms
78,720 KB
testcase_29 AC 296 ms
79,360 KB
testcase_30 AC 301 ms
78,604 KB
testcase_31 AC 280 ms
77,888 KB
testcase_32 AC 316 ms
79,360 KB
testcase_33 AC 309 ms
79,232 KB
testcase_34 AC 288 ms
79,624 KB
testcase_35 AC 297 ms
79,128 KB
testcase_36 AC 312 ms
78,720 KB
testcase_37 AC 316 ms
78,580 KB
testcase_38 AC 333 ms
79,236 KB
testcase_39 AC 318 ms
79,104 KB
testcase_40 AC 306 ms
79,012 KB
testcase_41 AC 300 ms
78,900 KB
testcase_42 AC 329 ms
78,848 KB
testcase_43 AC 323 ms
79,276 KB
testcase_44 AC 311 ms
78,628 KB
testcase_45 AC 301 ms
79,488 KB
testcase_46 AC 328 ms
79,080 KB
testcase_47 AC 46 ms
51,840 KB
testcase_48 AC 46 ms
52,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p,r=map(int,input().split())
f=lambda a:pow(a,(p-1)//2,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,r,v=(p+1)//2,(1,0),(b,1)
    while e:
        if e&1:r=h(r,v)
        v,e=h(v,v),e//2
    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