我用下面的代碼搞定了這題:
import math
while True:
try:
a, b, c = list(map(float, input().split()))
foo = b*b - (4*a*c)
assert foo >= 0
if foo > 0:
foo = math.sqrt(foo)
x1 = (-b + foo) / 2*a
x2 = (-b - foo) / 2*a
print("Two different roots x1={} , x2={}".format(int(max(x1,x2)), int(min(x1,x2))))
else:
print("Two same roots x={:d}".format(int(-b / (2*a))))
except EOFError:
break
except AssertionError:
print("No real root")
提交後他也AC了,可是解題統計卻還是顯示未嘗試,這是網站bug還是我沒通過?