#32234: python 卡80%


a0905915829@gmail.com (204-31莊岫芳)


a,b,c = input().split()
x = (int(b)**2-4*int(a)*int(c))

if x>0:
   x1 = (-int(b)+x**0.5)//(2*int(a))
   x2 = (-int(b)-x**0.5)//(2*int(a))  
   print('Two different roots x1='+str(x1)+','+'x2='+str(x2))

elif x==0:
   x1 = (-1*int(b)+x**5)//(2*int(a))
   print('Two same roots x='+str(x1))

else:
   print('No real root')

 

想請問一下要怎麼把two different roots的答案去小數點

ex: x1=2.0 就不通過了

系統說一定要是 x1=2

#32237: Re: python 卡80%


cges30901 (cges30901)


a,b,c = input().split()
x = (int(b)**2-4*int(a)*int(c))

if x>0:
   x1 = (-int(b)+x**0.5)//(2*int(a))
   x2 = (-int(b)-x**0.5)//(2*int(a))  
   print('Two different roots x1='+str(x1)+','+'x2='+str(x2))

elif x==0:
   x1 = (-1*int(b)+x**5)//(2*int(a))
   print('Two same roots x='+str(x1))

else:
   print('No real root')

 

想請問一下要怎麼把two different roots的答案去小數點

ex: x1=2.0 就不通過了

系統說一定要是 x1=2


可以把x**0.5改成int(x**0.5)