fork download
  1. #Square Root
  2. def sqrt( n ):
  3.  
  4. x = n
  5. y = 1.0
  6. eps = 0.000001
  7.  
  8. while x - y > eps:
  9. x = (x + y) / 2
  10. y = n / x
  11. return x
  12.  
  13. # ax^2 + bx + c = 0
  14. def QuadraticEquation(a, b, c):
  15. if a != 0:
  16. discriminant = b ** 2 - 4 * a * c
  17. if discriminant > 0 and a > 0:
  18. root1 = (-b - sqrt(discriminant))/(2*a)
  19. root2 = (-b + sqrt(discriminant))/(2*a)
  20. return 2, root1, root2
  21. elif discriminant > 0 and a < 0:
  22. root1 = (-b + sqrt(discriminant))/(2*a)
  23. root2 = (-b - sqrt(discriminant))/(2*a)
  24. return 2, root1, root2
  25. elif discriminant == 0:
  26. root1 = root2 = -b/(2*a)
  27. return 1, root1
  28. else:
  29. return [0]
  30. else:
  31. if b == 0 and c == 0:
  32. return [-1]
  33. elif b != 0:
  34. root1 = -c/b
  35. return [1, root1]
  36. else:
  37. return[0]
  38. A, B, C = [int(i) for i in input().split()]
  39. print(*QuadraticEquation(A, B, C), sep='\n')
Success #stdin #stdout 0.03s 9868KB
stdin
1223 -23532 1232
stdout
2
0.05249747447913724
19.188712664523315