結果

問題 No.551 夏休みの思い出(2)
ユーザー pekempeypekempey
提出日時 2017-07-29 03:14:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 490 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 260,608 KB
最終ジャッジ日時 2024-04-19 03:55:33
合計ジャッジ時間 7,396 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
57,472 KB
testcase_01 AC 46 ms
53,120 KB
testcase_02 AC 55 ms
55,296 KB
testcase_03 AC 122 ms
76,544 KB
testcase_04 AC 146 ms
77,568 KB
testcase_05 AC 210 ms
77,956 KB
testcase_06 AC 215 ms
77,996 KB
testcase_07 AC 48 ms
53,760 KB
testcase_08 AC 47 ms
54,016 KB
testcase_09 AC 47 ms
53,888 KB
testcase_10 AC 47 ms
53,120 KB
testcase_11 AC 47 ms
53,504 KB
testcase_12 AC 47 ms
53,760 KB
testcase_13 AC 47 ms
53,760 KB
testcase_14 AC 46 ms
53,248 KB
testcase_15 AC 45 ms
53,632 KB
testcase_16 AC 46 ms
53,248 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

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),u[0]*v[1]+u[1]*v[0])
    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