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. // your code goes here
  13. Scanner sc=new Scanner(System.in);
  14. int t=sc.nextInt();
  15. while(t-->0)
  16. {
  17. String s=sc.next();
  18. int n=Integer.parseInt(s);
  19. int a=Integer.parseInt(s.substring(0,2));
  20. int b=Integer.parseInt(s.substring(2,4));
  21. int sum=a+b;
  22.  
  23. if(sum*sum ==n)
  24. System.out.println(a+" "+b);
  25. else
  26. System.out.println("-1");
  27. }
  28. }
  29. }
Success #stdin #stdout 0.16s 58764KB
stdin
5
0001
1001
1000
4900
2025
stdout
0 1
-1
-1
-1
20 25