結果

問題 No.551 夏休みの思い出(2)
ユーザー pekempeypekempey
提出日時 2017-07-29 03:14:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 490 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 21,064 KB
最終ジャッジ日時 2024-04-19 03:54:41
合計ジャッジ時間 6,921 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 33 ms
10,752 KB
testcase_03 AC 43 ms
10,880 KB
testcase_04 AC 55 ms
10,752 KB
testcase_05 AC 89 ms
10,752 KB
testcase_06 AC 118 ms
10,752 KB
testcase_07 AC 32 ms
10,752 KB
testcase_08 AC 31 ms
10,880 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 30 ms
10,752 KB
testcase_12 AC 30 ms
10,752 KB
testcase_13 AC 30 ms
10,752 KB
testcase_14 AC 31 ms
10,752 KB
testcase_15 AC 31 ms
10,752 KB
testcase_16 AC 30 ms
10,880 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