fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.math.*;
  7.  
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int a = 2147483647;
  13. int m = 3;
  14. long _A = (long) a;
  15. BigInteger A = BigInteger.valueOf(a);
  16. BigInteger M = BigInteger.valueOf(m);
  17. // Compute with BigInteger
  18. int x = A.multiply(A).mod(M).intValue();
  19. //compute with long
  20. int y = (int) ((_A*_A) %m);
  21. System.out.println(x);
  22. System.out.println(y);
  23. }
  24. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
1
1