forked from DVB7781/hacktoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXxOoRr.cpp
More file actions
55 lines (46 loc) · 970 Bytes
/
XxOoRr.cpp
File metadata and controls
55 lines (46 loc) · 970 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
43
44
45
46
47
48
49
50
51
52
53
54
55
//problem link - https://www.codechef.com/JULY21C/problems/XXOORR
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin >> T;
int answer;
int m, k;
while(T--)
{
cin >> m >> k;
vector<int> a(m);
for(int& i : a)
{
cin >> i;
}
vector<int> nSetBit(32);
int count;
int term;
for(int bit=0; bit<=30; bit++)
{
count = 0;
for(int& i : a){
if(i%2!=0){
count++;
}
i = i/2;
}
nSetBit[bit] = count;
}
answer = 0;
for(int bit=0; bit<=30; bit++)
{
if(nSetBit[bit]%k == 0){
answer += nSetBit[bit]/k;
}
else
{
answer += nSetBit[bit]/k + 1;
}
}
cout << answer << endl;
}
return 0;
}