git reimport
This commit is contained in:
45
archive/2017.03/2017.03.05 - unsorted/D.java
Normal file
45
archive/2017.03/2017.03.05 - unsorted/D.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class D {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int k = in.nextInt();
|
||||
int M = 1 << 16;
|
||||
int[] a = new int[M];
|
||||
for (int i = 0; i < n; i++) {
|
||||
int x = in.nextInt();
|
||||
a[x]++;
|
||||
}
|
||||
|
||||
List<Integer> masks = new ArrayList<>();
|
||||
for (int i = 0; i < M; i++) {
|
||||
if (Integer.bitCount(i) == k) {
|
||||
masks.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
long answer = 0;
|
||||
for (int i = 0; i < M; i++) {
|
||||
if (a[i] == 0) {
|
||||
continue;
|
||||
}
|
||||
for (int mask : masks) {
|
||||
if ((i ^ mask) < i) {
|
||||
answer += a[i] * a[i ^ mask];
|
||||
}
|
||||
if ((i ^ mask) == i) {
|
||||
answer += a[i] * (a[i] - 1) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.println(answer);
|
||||
}
|
||||
|
||||
}
|
31
archive/2017.03/2017.03.05 - unsorted/D.task
Normal file
31
archive/2017.03/2017.03.05 - unsorted/D.task
Normal file
@@ -0,0 +1,31 @@
|
||||
1 D
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
2
|
||||
0
|
||||
11 4 1
|
||||
0 3 2 1
|
||||
1 4
|
||||
1
|
||||
1
|
||||
27 6 0
|
||||
200 100 100 100 200 200
|
||||
1 6
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.D
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.05
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
Reference in New Issue
Block a user