-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinarythree.cpp
More file actions
42 lines (38 loc) · 794 Bytes
/
binarythree.cpp
File metadata and controls
42 lines (38 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
long long int n;
for(int i = 0; i < t; i++){
scanf("%lld", &n);
long long int arr[n+2];
for(long long int j = 0; j < n; j++){
scanf("%lld", &arr[j]);
}
long long int total = 0;
long long int hasil = 0;
long long int jumlah_biton = 0;
long long int biton;
for(int j = 0; j < n; j++){
for(int k = j + 1; k < n; k++){
hasil = arr[j] ^ arr[k];
total++;
biton = 0;
for(int m = 0; m <= 20; m++){
if((hasil & (1 << m)) > 0){
biton++;
}
if(biton >= 3){
break;
}
}
if(biton >= 3){
jumlah_biton++;
}
}
}
printf("Case #%d: %d %d\n", i+1, jumlah_biton, (total - jumlah_biton));
}
return 0;
}