시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 302 15 8 9.412%

문제

삼차 방정식 Ax3 + Bx2 + Cx + D = 0 의 모든 실수 해를 찾는 프로그램을 작성하시오.

입력으로 주어지는 방정식은 정수 해를 적어도 한 개 갖는다.

A, B, C, D는 -2,000,000보다 크거나 같고, 2,000,000보다 작거나 같은 정수이고, A는 0이 아니다. 모든 해는 -1,000,000보다 크거나 같고, 1,000,000보다 작거나 같다.

입력

첫째 줄에 테스트 케이스의 개수 N (0 < N < 100)이 주어진다. 다음 N개 줄에는 삼차 방정식의 계수 A, B, C, D가 한 줄에 하나씩 주어진다.

출력

입력으로 주어진 방정식마다 모든 실수 해를 오름차순으로 출력한다. 해의 절대/상대 오차는 10-4까지 허용한다. 중근이 존재하는 경우에는 한 번만 출력한다.

예제 입력 1

2
2 -7 7 -2
2 0 0 0

예제 출력 1

0.5000 1.0000 2.0000
0.0000

힌트

W3sicHJvYmxlbV9pZCI6Ijk3MzUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMwYmNcdWNjMjggXHViYzI5XHVjODE1XHVjMmRkIFx1ZDQ4MFx1YWUzMCIsImRlc2NyaXB0aW9uIjoiPHA+XHVjMGJjXHVjYzI4IFx1YmMyOVx1YzgxNVx1YzJkZCBBeDxzdXA+MzxcL3N1cD4gKyBCeDxzdXA+MjxcL3N1cD4gKyBDeCArIEQgPSAwJm5ic3A7XHVjNzU4IFx1YmFhOFx1YjRlMCBcdWMyZTRcdWMyMTggXHVkNTc0XHViOTdjIFx1Y2MzZVx1YjI5NCBcdWQ1MDRcdWI4NWNcdWFkZjhcdWI3YThcdWM3NDQgXHVjNzkxXHVjMTMxXHVkNTU4XHVjMmRjXHVjNjI0LjxcL3A+XHJcblxyXG48cD5cdWM3ODVcdWI4MjVcdWM3M2NcdWI4NWMgXHVjOGZjXHVjNWI0XHVjOWMwXHViMjk0IFx1YmMyOVx1YzgxNVx1YzJkZFx1Yzc0MCBcd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CBzb2x1dGlvbiBtdXN0IGJlIHJvdW5kZWQgb2ZmIHRvIHRoZSBuZWFyZXN0IHRlbiB0aG91c2FuZHRoIGFuZCBtdXN0IGJlIHByaW50ZWQgd2l0aCBleGFjdGx5IGZvdXIgZGlnaXRzIGFmdGVyIHRoZSBkZWNpbWFsIHBvaW50LiBUd28gb3IgbW9yZSBkaXN0aW5jdCByZWFsIHNvbHV0aW9ucyBtdXN0IGJlIHNlcGFyYXRlZCBieSBleGFjdGx5IG9uZSBzcGFjZS48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

ACM-ICPC > Regionals > Asia > Philippines > Philippines Multi-Provincial Programming Contest > Philippines Multi-Provincial Programming Contest 2013 C번