Quadratic equation - simple version


Submit solution

Points: 10
Time limit: 2.0s
Memory limit: 62M

Authors:
Problem type
Allowed languages
Java 19, Java 8

題目說明

求解二元一次方程式 \begin{equation} ax^2 + bx + c =0 \end{equation}

給定已知a, b, c,且b^2-4ac > 0,請求解x。

提示

\begin{equation} x = \frac{-b\pm\sqrt(b^2-4ac)}{2a} \end{equation}

輸入

由鍵盤輸入一整數a (a>0), 整數b, 整數c 且b^2-4ac > 0

輸出

兩相異根 (小者在前 大者在後)

sample input & output

輸入 輸出
DataSet1 1 -5 6 2.0 3.0
DataSet2 536870912 65432 1 -1.039595852879811E-4 -1.791701211649889E-5
DataSet3 100000 -500000 600000 2.0 3.0

Comments

There are no comments at the moment.