結果

問題 No.551 夏休みの思い出(2)
ユーザー pekempeypekempey
提出日時 2017-07-29 03:23:50
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 506 bytes
コンパイル時間 1,280 ms
コンパイル使用メモリ 76,712 KB
実行使用メモリ 266,316 KB
最終ジャッジ日時 2024-04-19 03:58:42
合計ジャッジ時間 8,855 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,400 KB
testcase_01 AC 76 ms
75,428 KB
testcase_02 AC 96 ms
77,312 KB
testcase_03 AC 136 ms
79,628 KB
testcase_04 AC 153 ms
79,656 KB
testcase_05 AC 204 ms
81,240 KB
testcase_06 AC 210 ms
80,912 KB
testcase_07 AC 76 ms
75,396 KB
testcase_08 AC 76 ms
75,652 KB
testcase_09 AC 76 ms
75,764 KB
testcase_10 AC 76 ms
75,816 KB
testcase_11 AC 78 ms
75,392 KB
testcase_12 AC 78 ms
75,584 KB
testcase_13 AC 78 ms
75,548 KB
testcase_14 AC 78 ms
75,812 KB
testcase_15 AC 78 ms
75,648 KB
testcase_16 AC 77 ms
75,648 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,raw_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(input()):
    a,b,c=map(int,raw_input().split())
    d=b*b-4*a*c
    a=pow(2*a,p-2,p)
    D=h(d)
    if f(d):print ' '.join(map(str,sorted(set([(D-b)*a%p,(-b-D)*a%p]))))
    else:print -1
0