#23249: if 判斷式


richardlee281920@gmail.com (EE)

學校 : 不指定學校
編號 : 137011
來源 : [1.165.63.140]
最後登入時間 :
2020-11-01 21:50:36
a006. 一元二次方程式 | From: [1.165.63.140] | 發表日期 : 2020-11-01 20:42

a,b,c = input().split()

a = int(a)

b = int(b)

c = int(c)

 

factor = b ** 2 - 4 * a *c  #判別方程式在x軸有幾個解

if factor > 0:

  r1 = (-b + factor ** 0.5) / 2 / a

  r2 = (-b - factor ** 0.5) / 2 / a

  print("Two different roots x1=", int(r1), " , x2=", int(r2), sep = "")

elif factor == 0:

  r1 = (-b) / 2 / a

  r2 = r1

  print("Two same roots x=", int(r1), sep = "")

else:

  print("No real root")

 

 

 
ZeroJudge Forum