qwerty787788

Untitled

May 21st, 2016
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1.     final int T = BigInteger.valueOf(14000000).nextProbablePrime().intValue();
  2.     long[] was = new long[T];
  3.     int[] sz = new int[T];
  4.  
  5.     void add(int p, int q) {
  6.         long val = ((long) p << 32) ^ q;
  7.         int pos = (int) (val % T);
  8.         while (true) {
  9.             if (was[pos] == 0 || was[pos] == val) {
  10.                 break;
  11.             }
  12.             pos++;
  13.             if (pos == T) {
  14.                 pos = 0;
  15.             }
  16.         }
  17.         was[pos] = val;
  18.         sz[pos]++;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment