fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone {
  6.  
  7. public static void main (String[] args) throws java.lang.Exception {
  8. int MOD = 1000_000_007;
  9. int a = 1000_000;
  10. int b = 1000_000;
  11. int c = ( a * b ) % MOD;
  12. System.out.println( c );
  13.  
  14. // first trick
  15. long c2 = ( 1L * a * b ) % MOD;
  16. System.out.println( c2 );
  17.  
  18. // or use bigger type
  19. long A = a;
  20. long B = b;
  21. long c3 = ( A * B ) % MOD;
  22. System.out.println( c3 );
  23. }
  24. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
-727379968
999993007
999993007