#21972: [python]交出後只有80%


zz5120937@gmail.com (meteor(梁欣宇))

學校 : 逢甲大學
編號 : 125986
來源 : [140.134.27.1]
最後登入時間 :
2022-12-20 09:17:59
a006. 一元二次方程式 | From: [123.110.176.148] | 發表日期 : 2020-08-06 16:01

while True:
try:
a, b, c = map(int, input().split(' '))
except:
break;
D = (b * b) - 4 * a * c
if D > 0:
x1 = (-b + (b * b - 4 * a * c) ** 0.5) / (2 * a)
x2 = (-b - (b * b - 4 * a * c) ** 0.5) / (2 * a)
print('Two different roots x1=%d , x2=%d' % (x1, x2))
elif D == 0:
x1 = -b / 2 * a
print('Two same roots x=%d' % x1)
elif D < 0:
print('No real root')
 
#21973: Re:[python]交出後只有80%


ilovechen0117@gmail.com (Diana)

學校 : 不指定學校
編號 : 126113
來源 : [122.116.85.97]
最後登入時間 :
2020-08-27 15:41:49
a006. 一元二次方程式 | From: [122.116.85.97] | 發表日期 : 2020-08-06 16:46

while True:
try:
a, b, c = map(int, input().split(' '))
except:
break;
D = (b * b) - 4 * a * c
if D > 0:
x1 = (-b + (b * b - 4 * a * c) ** 0.5) / (2 * a)
x2 = (-b - (b * b - 4 * a * c) ** 0.5) / (2 * a)
print('Two different roots x1=%d , x2=%d' % (x1, x2))
elif D == 0:
x1 = -b / 2 * a
print('Two same roots x=%d' % x1)
elif D < 0:
print('No real root')

請修改 x1 = -b / 2 * a 為 x1 = -b / (2 * a)

 
ZeroJudge Forum