結果

問題 No.551 夏休みの思い出(2)
ユーザー pekempeypekempey
提出日時 2017-07-29 03:09:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 486 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2024-04-19 03:54:00
合計ジャッジ時間 6,054 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
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==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