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

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.





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值