Guest User

SIMPROB solution

a guest
Sep 18th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) throws NumberFormatException, IOException {
  8.  
  9.        
  10.         BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
  11.         int t=Integer.parseInt(r.readLine());
  12.         while(t-->0)
  13.         {
  14.             String[] s=r.readLine().split(" ");
  15.             long a=Integer.parseInt(s[0]);
  16.             long b=Integer.parseInt(s[1]);
  17.             long c=Integer.parseInt(s[2]);
  18.             if(b<=0){System.out.println("No Roots");}
  19.             else{
  20.             double d=(b*b)-(4*a*c);
  21.             if(d<0 )    {System.out.println("No Roots");}
  22.             else{
  23.             d=Math.sqrt(d);
  24.                 System.out.println(""+((b*-1)+d)/(2*a));
  25.                 System.out.println(""+((b*-1)-d)/(2*a));
  26.             }
  27.         }}
  28.        
  29.     }
  30.  
  31. }
Add Comment
Please, Sign In to add comment