fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone{
  6. public static void main (String[] args) throws java.lang.Exception{
  7. int a,b,c,d;
  8. Scanner x = new Scanner(System.in);
  9. a = x.nextInt();
  10. b = x.nextInt();
  11. c = x.nextInt();
  12. d = (b*b)-(4*a*c);
  13. if(d > 0){
  14. double x1,x2;
  15. x1 = (-b+Math.sqrt(d))/(2*a);
  16. x2 = (-b-Math.sqrt(d))/(2*a);
  17. System.out.print("Two roots: "+((x1 > x2)?x2:x1)+" "+((x1>x2)?x1:x2));
  18. } else if (d == 0){
  19. System.out.print("One root: " +(-b/(2*a)));
  20. } else {
  21. System.out.print("No roots");
  22. }
  23. }
  24. }
Success #stdin #stdout 0.06s 711680KB
stdin
 1 6 9
stdout
One root: -3