#24606: [PY] 請問錯在哪裡?測試有通過但正式沒通過。


a105050084@mail.shu.edu.tw (世新闕崇恩)


Hi all,

以下

str1 = input()

 

a, b, c = str1.split(' ')

a = int(a)

b = int(b)

c = int(c)

 

root = b*b-4*a*c

if root < 0:

    print('No real root')

elif root >= 0:

    root1 = -b/2*a +(b*b-4*a*c)**0.5/2*a

    root2 = -b/2*a - (b*b-4*a*c)**0.5/2*a

    root1 = int(root1)

    root2 = int(root2)

    if root > 0:

        print('Two different roots x1=',root1,' , x2=',root2, sep="")

    elif root == 0:

        print('Two same roots x=',root1, sep="")

 

 

謝謝

#24607: Re:[PY] 請問錯在哪裡?測試有通過但正式沒通過。


asnewchien@gmail.com (david)


PS: 答案均為整數,若有兩個根則大者在前