Untitled
unknown
plain_text
3 years ago
1.5 kB
26
Indexable
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double a = sc.nextInt();
double b = sc.nextInt();
double c = sc.nextInt();
if(a==0){
if(b==0){
if(c==0){
System.out.println("INF");
}else{
System.out.println("NO");
}
}else{
if(c==0){
System.out.println("0.00");
}else{
System.out.printf("%.2f",-c/b);
}
}
}else{
double delta = b * b - 4 * a * c;
double x1 = (-b + Math.sqrt(delta)) / (2 * a);
double x2 = (-b - Math.sqrt(delta)) / (2 * a);
if(b==0){
if(c==0){
System.out.printf("%.2f",0);
System.exit(0);
}
}
if(delta < 0){
System.out.println("NO");
}else if(delta == 0){
System.out.printf("%.2f",-b/(2*a));
}else{
if(x1 > x2){
System.out.printf("%.2f %.2f",x2,x1);
}else{
System.out.printf("%.2f %.2f",x1,x2);
}
}
}
}
}
Editor is loading...