fork download
  1. import java.io.BufferedWriter; import java.io.OutputStreamWriter;
  2.  
  3. class ClassTest { public static void main(String args[] ) throws Exception { try{ int T=0 ,read; BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
  4.  
  5. // No of Test Cases
  6. while((read = System.in.read()) != '\n' )
  7. { if( read != '\r' ) T = T*10 + read -48 ; }
  8.  
  9.  
  10. while(T --> 0)
  11. {
  12. int A=0,B=0 ;
  13.  
  14. while((read = System.in.read()) != ' ' )
  15. { if( read != '\r' && read != '-') A = A*10 + read -48 ; }
  16.  
  17. while((read = System.in.read()) != '\n' && read != -1 )
  18. { if( read != '\r' && read != '-') B= B*10 + read -48 ; }
  19.  
  20. int a =Math.max(A,B);
  21. int b =Math.min(A,B);
  22.  
  23. float max =(float)Math.sqrt(a*a +b*b);
  24. float min =(float)Math.sqrt((a*a) - (b*b));
  25.  
  26. out.write(min + " ");
  27. out.write(max + "\n");
  28. }
  29. out.flush();
  30. out.close();
  31. System.in.close();
  32. }catch(Exception e){}
  33. }
  34. }
Success #stdin #stdout 0.07s 380224KB
stdin
2
1 822
999 8
stdout
821.9994 822.0006
998.96796 999.03204