CF 530A(Quadratic equation-注意(-b+sqrt(Δ))/2a<(-b-sqrt(Δ))/2a的情况)[Picat]

来源:互联网 发布:dncy女装淘宝上有卖吗 编辑:程序博客网 时间:2024/04/29 22:35

A. Quadratic equation
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a quadratic equation with integer coefficients A * X2 + B * X + C = 0. It is guaranteed that A ≠ 0 and that the equation has at least one real root. Output the roots of the equation.

Input

The only line of input contains integers A, B and C ( - 1000 ≤ A, B, C ≤ 1000, A ≠ 0), separated by spaces.

Output

Output the roots of the equation in increasing order. If the equation has a single root of multiplicity 2, output it once. The root is considered to be correct if its absolute or relative error does not exceed 10 - 4.

Sample test(s)
input
1 -2 1
output
1
input
1 0 -1
output
-1 1
input
2 -3 1
output
0.5 1

简单的送分题。

BUG 请注意 


import math.main =>  A = read_real(),  B = read_real(),  C = read_real(),  D = B*B-4*A*C,  E := sqrt(D),  F :=(-B+E)/(2.0*A),  G :=(-B-E)/(2.0*A),  if (F=G) then  printf("%f%n", F )  else    printf("%f %f%n", min(G,F), max(G,F) )  end.





0 0
原创粉丝点击