4325 - 대수: 2차방정식 풀이

Time Limit: 1s Memory Limit: 128MB

Submissions: 2906 Solved: 630
Description

2차 방정식의 해는 다음 공식을 통해서 구할 수 있습니다.

The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula:  

위 식에서 b^2-4ac 는 2차방정식의 판별식이라고 합니다. 만약 2차 방정식의 판별식이 0보다 크다면 2개의 실수해를 가지고, 0이라면 1개의 실수해를 가지고, 0보다 작다면 0개의 실수해를 가집니다. a, b, c의 값을 입력으로 받아 해를 출력하는 프로그램을 작성하세요.

b^2-4ac is called the discriminant of the quadratic equation. If it is positive, the equation has two real roots. If it is zero, the equation has one root. If it is negative, the equation has no real roots. Write a program that prompts the user to enter values for a, b, and c and displays the result based on the discriminant. 

 

Input

* Line 1 : 실수 a (범위는 -100~100 이고 0이 아님)

* Line 2 : 실수 b (범위는 -100~100)

* Line 3 : 실수 c (범위는 -100~100)

Output

* Line 1 : 두개의 실수해 중에서 큰 값을 출력 (소수점 첫째자리에서 내림. 실수해가 없을 경우 숫자출력 대신 complex 라는 문자열만 출력. 예: 11.713는 11.7로 출력, 11.0는 11.0로 출력, -2.61는 -2.7로 출력) 

Sample Input
1
3
1
Sample Output
-0.4
Hint
  • Math.pow(x, 0.5)
  • 소수점 한자리까지 출력 System.out.printf("%.1f\n", 0.6789);
Source

JAVA2015 PE3.1