-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMAX_CHOCOLATES.cpp
More file actions
66 lines (55 loc) · 938 Bytes
/
MAX_CHOCOLATES.cpp
File metadata and controls
66 lines (55 loc) · 938 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
56
57
58
59
60
61
62
63
64
65
66
////////////////////////////////chunnu//////////////////////////////////////////
#include <iostream>
using namespace std;
int main()
{
int R;
cout<<"enter money"<<endl;
cin>>R;
int q;
int sum;
if(R%2==0)
{
sum=R+(R/2 )-1;
cout<<sum;
}
else if(R%2==1)
{
q=R/3;
if(((R-1)/2)%2==1)
{
sum=R+q+q/3+1;
cout<<sum;
}
else
{
sum=R+q+q/3;
cout<<sum;
}
}
return 0;
}
//////////////////////////////////////////munnu////////////////////
#include <iostream>
using namespace std;
int main()
{
int q;
cout<<"enter money"<<endl;
cin>>q;
int r=0;
int count=0;
int sum=0;
cout<<"total number of chocolates:"<<endl;
while(q!=0)
{
sum+=q;
r+=q%3;
q=q/3;
}
sum+= r/3;
{
cout<<sum;
}
return 0;
}