fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int q,n1,n2,t1;
  13. float a1,a2;
  14. String s;
  15. String[] s1;
  16. q=Integer.parseInt(br.readLine());
  17. while(q-->0){
  18. s=br.readLine();
  19. s1=s.split(" ");
  20. n1=Integer.parseInt(s1[0]);
  21. n2=Integer.parseInt(s1[1]);
  22. if(n2>n1){
  23. t1=n1;
  24. n1=n2;
  25. n2=t1;
  26. }
  27. a1=(float)Math.sqrt((n1*n1)+(n2*n2));
  28. a2=(float)Math.sqrt((n1*n1)-(n2*n2));
  29. System.out.println(a2+" "+a1);
  30. }
  31.  
  32. }
  33. }
Success #stdin #stdout 0.07s 380224KB
stdin
3
4 5
10 12
10 20
stdout
3.0 6.4031243
6.6332498 15.6205
17.320509 22.36068