Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final int T = BigInteger.valueOf(14000000).nextProbablePrime().intValue();
- long[] was = new long[T];
- int[] sz = new int[T];
- void add(int p, int q) {
- long val = ((long) p << 32) ^ q;
- int pos = (int) (val % T);
- while (true) {
- if (was[pos] == 0 || was[pos] == val) {
- break;
- }
- pos++;
- if (pos == T) {
- pos = 0;
- }
- }
- was[pos] = val;
- sz[pos]++;
- }
Advertisement
Add Comment
Please, Sign In to add comment