The oldest problem about a snail (in C ++):
The snail crawls along a vertical pole with a height of h meters, climbing a meter in a day, and going b meters in a night. On which day will the snail crawl to the top of the pole?
The program receives natural numbers h, a, b as input and should output one natural number. It is guaranteed that a> b.
At the decision of this task it is impossible to use the conditional instruction if and cycles.
There is a solution, but I cannot understand it. Can you explain in detail what and how?
decision:
1 + h0 / shag + (h0% shag + shag - 1) / shag)
(((h - a) + b) / (a - b)) - (a - b) ;
Will the answer be correct? - Max Skripkin