Problem Description
Loading...
Problem Analysis
The idea is
Tom currently has n cigarettes, and every k cigarette butts can be rolled into a new cigarette
Find the maximum number of cigarettes Tom can smoke
The code idea is to simulate the smoking process
loop over the smoking process
track changes in cigarette butts and new cigarettes
until there are no new cigarettes left
then the loop terminates
cpp
| |
The standard solution’s loop is simpler
it treats n/k as the currently available un-smoked new cigarettes
and uses n to record the current cigarette butts
cpp
| |
Problem link:cigarettes