-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchocoFeast.cpp
37 lines (31 loc) · 849 Bytes
/
chocoFeast.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
#include <iostream>
using namespace std;
int wrapperCount(int tradePrice, int wrappers){
int newChoco = 0;
if(wrappers >= tradePrice){
int newWrappers = wrappers / tradePrice;
wrappers %= tradePrice;
wrappers += newWrappers;
newChoco = newWrappers;
if(wrappers >= tradePrice){
return newChoco + wrapperCount(tradePrice, wrappers);
}
}
return newChoco;
}
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int t,n,c,m;
cin>>t;
while(t--){
cin>>n>>c>>m;
int answer=0;
// Computer answer
int chocoCount = n / c;
int wrappers = chocoCount;
chocoCount += wrapperCount(m, wrappers);
answer = chocoCount;
cout<<answer<<endl;
}
return 0;
}