fork download
  1. import java.io.*;
  2. import java.util.*;
  3. import java.math.*;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. Scanner in = new Scanner(System.in);
  8. PrintWriter out = new PrintWriter(System.out);
  9.  
  10. long m = in.nextLong();
  11. long n = in.nextLong();
  12. BigInteger bi1, bi2, bi3;
  13. bi1 = BigInteger.valueOf(m);
  14. bi2 = BigInteger.valueOf(n);
  15. bi3 = bi1.gcd(bi2);
  16. long g = bi3.longValue();
  17. m /= g;
  18. n /= g;
  19. out.print((n + m - 2) + " ");
  20. if (n % 2 == 0 & m % 2 != 0) out.print(4);
  21. if (n % 2 != 0 & m % 2 != 0) out.print(3);
  22. if (n % 2 != 0 & m % 2 == 0) out.print(2);
  23.  
  24. out.flush();
  25. }
  26. }
Success #stdin #stdout 0.07s 2184192KB
stdin
12 33
stdout
13 2