We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Implementation
- Chocolate Feast
- Discussions
Chocolate Feast
Chocolate Feast
Sort by
recency
|
1263 Discussions
|
Please Login in order to post a comment
This problem is a geometric series so can be solved with maths.
Here is my easy c++ solution , you can watch the explanation here : https://youtu.be/RZti_qPbiAA
def chocolateFeast(n, c, m): bars = n//c wrap = bars while w:=wrap//m: bars += w wrap = w + wrap% m return bars
int chocolates = n / c; int exchange_wrappers = chocolates;