-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCIELRCPT.cpp
52 lines (47 loc) · 1.7 KB
/
CIELRCPT.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
/*
go to the CIELRCPT problem at www.codechef.com
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
int t,p;
cin>>t;
while(t--){
cin>>p;
int a[12];
for(int i=0; i<=11; i++){
a[i]=pow(2,i);
}
int bill = 0, counter=0;
while(bill<p){
int diff = p - bill;
if(diff>=a[11])
bill+=a[11];
else if(diff>=a[10] && diff <a[11])
bill+=a[10];
else if(diff>=a[9] && diff <a[10])
bill+=a[9];
else if(diff>=a[8] && diff <a[9])
bill+=a[8];
else if(diff>=a[7] && diff <a[8])
bill+=a[7];
else if(diff>=a[6] && diff <a[7])
bill+=a[6];
else if(diff>=a[5] && diff <a[6])
bill+=a[5];
else if(diff>=a[4] && diff <a[5])
bill+=a[4];
else if(diff>=a[3] && diff <a[4])
bill+=a[3];
else if(diff>=a[2] && diff <a[3])
bill+=a[2];
else if(diff>=a[1] && diff <a[2])
bill+=a[1];
else if(diff>=a[0] && diff <a[1])
bill+=a[0];
counter++;
}
cout<<counter<<endl;
}
return 0;
}