fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. double a, b, x;
  10. Scanner in = new Scanner(System.in);
  11. while (in.hasNextDouble())
  12. {
  13. a = in.nextDouble();
  14. b = in.nextDouble();
  15. if (a == 0)
  16. {
  17. if (b == 0) System.out.println("Infinite set of roots; ");
  18. else System.out.println("No roots; ");
  19. }
  20. else
  21. {
  22. x = (-b/a == -0)? b/a : -b/a;
  23. System.out.println(x + "; ");
  24. }
  25. }
  26. }
  27. }
Success #stdin #stdout 0.14s 31164KB
stdin
1 1 -6 -2 1 -2 10 0
stdout
-1.0; 
-0.3333333333333333; 
2.0; 
0.0;