a,b,c=map(int,input().split())
d = b**2 - 4*a*c
if d < 0:
print('No real root')
elif d ==0:
r = int(-b/2*a)
print('Two same roots x={}'.format(r))
else:
n = int(d ** 0.5)
r1 = int((-b + n ) / (2*a))
r2 = int((-b - n ) / (2*a))
if r1 < r2 :
r1,r2 = r2,r1
print('Two different roots x1={} , x2={}'.format(r1,r2))
測試與送出的前三個測資都隊
但在第四個測資發生錯誤
您的答案為: Two same roots x=-4 正確答案為: Two same roots x=-1
a,b,c=map(int,input().split())
d = b**2 - 4*a*c
if d < 0:
print('No real root')
elif d ==0:
r = int(-b/2*a)
print('Two same roots x={}'.format(r))
else:
n = int(d ** 0.5)
r1 = int((-b + n ) / (2*a))
r2 = int((-b - n ) / (2*a))
if r1 < r2 :
r1,r2 = r2,r1
print('Two different roots x1={} , x2={}'.format(r1,r2))測試與送出的前三個測資都隊
但在第四個測資發生錯誤
您的答案為: Two same roots x=-4 正確答案為: Two same roots x=-1
2*a要用括號包起來