fork(7) 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. long start = System.currentTimeMillis();
  13. for (int i=0;i<1000000;i++) {
  14. for (int m=1;m<=12;m++){
  15. days1(m);
  16. }
  17. }
  18. long end = System.currentTimeMillis();
  19. System.out.println(end-start);
  20.  
  21. start = System.currentTimeMillis();
  22. for (int i=0;i<1000000;i++) {
  23. for (int m=1;m<=12;m++){
  24. days2(m);
  25. }
  26. }
  27. end = System.currentTimeMillis();
  28. System.out.println(end-start);
  29. }
  30.  
  31. public static int days1(int m) {
  32. return (0xEEFBB3>>(m-1)*2 & 0b11) + 28;
  33. }
  34.  
  35. public static int days2(int x) {
  36. return 28 + (x + (int)Math.floor(x/8)) % 2 + 2 % x + 2 * (int)Math.floor(1/x);
  37. }
  38. }
Success #stdin #stdout 1.22s 380224KB
stdin
Standard input is empty
stdout
15
1140