t | import math | t | import math |
| | | |
| def solve_biquadratic(a, b, c): | | def solve_biquadratic(a, b, c): |
| if a == 0: | | if a == 0: |
| if b == 0: | | if b == 0: |
| return -1 if c == 0 else 0 | | return -1 if c == 0 else 0 |
| y = -c / b | | y = -c / b |
| if y < 0: | | if y < 0: |
| return 0 | | return 0 |
| root = math.sqrt(y) | | root = math.sqrt(y) |
| return sorted([-root, root]) if root != 0 else [0] | | return sorted([-root, root]) if root != 0 else [0] |
| discriminant = b ** 2 - 4 * a * c | | discriminant = b ** 2 - 4 * a * c |
| if discriminant < 0: | | if discriminant < 0: |
| return 0 | | return 0 |
| y1 = (-b + math.sqrt(discriminant)) / (2 * a) | | y1 = (-b + math.sqrt(discriminant)) / (2 * a) |
| y2 = (-b - math.sqrt(discriminant)) / (2 * a) | | y2 = (-b - math.sqrt(discriminant)) / (2 * a) |
| roots = set() | | roots = set() |
| if y1 >= 0: | | if y1 >= 0: |
| roots.add(math.sqrt(y1)) | | roots.add(math.sqrt(y1)) |
| roots.add(-math.sqrt(y1)) | | roots.add(-math.sqrt(y1)) |
| if y2 >= 0: | | if y2 >= 0: |
| roots.add(math.sqrt(y2)) | | roots.add(math.sqrt(y2)) |
| roots.add(-math.sqrt(y2)) | | roots.add(-math.sqrt(y2)) |
| if not roots: | | if not roots: |
| return 0 | | return 0 |
| return sorted(roots) | | return sorted(roots) |
| try: | | try: |
| a, b, c = map(float, input().split(',')) | | a, b, c = map(float, input().split(',')) |
| except ValueError: | | except ValueError: |
| print('Ошибка: введите три числа через запятую.') | | print('Ошибка: введите три числа через запятую.') |
| exit() | | exit() |
| result = solve_biquadratic(a, b, c) | | result = solve_biquadratic(a, b, c) |
| if result == 0: | | if result == 0: |
| print(0) | | print(0) |
| elif result == -1: | | elif result == -1: |
| print(-1) | | print(-1) |
| else: | | else: |
| print(' '.join((f'{x:.1f}' if x.is_integer() else f'{x:.16f}' for x | | print(' '.join((f'{x:.1f}' if x.is_integer() else f'{x:.16f}' for x |
| in result))) | | in result))) |