AcWing 658. 一元二次方程公式
原题链接
简单
作者:
YYC
,
2020-08-01 14:45:42
,
所有人可见
,
阅读 466
import java.util.*;
public class Main{
public static void main(String... args){
Scanner in = new Scanner(System.in);
double a = in.nextDouble();
double b = in.nextDouble();
double c = in.nextDouble();
double t = b * b - 4 * a * c;
if (a == 0.d || t < 0){
System.out.println("Impossivel calcular");
return;
}
double ans1 = (-b + Math.sqrt(t)) / (2 * a);
double ans2 = (-b - Math.sqrt(t)) / (2 * a);
System.out.printf("R1 = %.5f\nR2 = %.5f", ans1, ans2);
return;
}
}