Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. a = float(input())
  2. b = float(input())
  3. c = float(input())
  4. D = b ** 2 - 4 * a * c
  5. if a == 0:
  6. if b == 0:
  7. if c == 0:
  8. print(3)
  9. else:
  10. print(-1)
  11. else:
  12. print(1, - c / b)
  13. else:
  14. if D > 0:
  15. x1 = (- b - D ** 0.5) / (2 * a)
  16. x2 = (- b + D ** 0.5) / (2 * a)
  17. if x1 % 1 == 0:
  18. x1 = int(x1)
  19. if x2 % 1 == 0:
  20. x2 = int(x2)
  21. if a > 0:
  22. print(2, x1, x2, sep=' ')
  23. else:
  24. print(2, x2, x1, sep=' ')
  25. elif D == 0:
  26. x = - b / (2 * a)
  27. if x % 1 == 0:
  28. x = int(x)
  29. print(1, x, sep=' ')
  30. else:
  31. print(-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement