-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecnuoj3036.cpp
59 lines (59 loc) · 1.03 KB
/
ecnuoj3036.cpp
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
56
57
58
59
#define ll long long
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int numof1(ll n)
{
int num=0;
while (n)
{
num++;
n=(n-1)&n;
}
return num;
}
bool cmp(ll a,ll b)
{
if(numof1(a)!=numof1(b))
{
return numof1(a)>numof1(b);
}
return a<b;
}
int main()
{
int N=0;
scanf("%d",&N);
int countN=0;
while (N>0)
{
int k=0;
scanf("%d",&k);
vector<ll> kv;
while (k>0)
{
ll t=0;
scanf("%lld",&t);
kv.push_back(t);
k--;
}
sort(kv.begin(),kv.end(),cmp);
cout<<"case #"<<countN<<":"<<endl;
for (size_t i = 0; i < kv.size(); i++)
{
if(i==kv.size()-1)
{
cout<<kv[i];
}
else
{
cout<<kv[i]<<" ";
}
}
cout<<endl;
N--;
countN++;
}
return 0;
}