Zoj 1494 climbing worm {4491}
A snail can climb from the bottom of a well every minute, and then fall down a certain distance in one minute. If the whole minute is not over, it will arrive at the wellhead. It will take one minute, if the minute of the climb arrives at the wellhead, it will not fall down. For the depth of the well, the distance between the climbing per minute is used to find the time to climb out of the wellhead.
Idea: This was a long time ago when I had the same question on hangdian in Activity Room. If the previous minute's climb does not reach the wellhead, there will be a certain distance and time to fall down, and the two distances and time cycles will be accumulated, until the distance from the next minute is greater than or equal to the distance from the wellhead, this minute is accumulated.
The code can be slightly improved. For more information, see comments.
# Include <stdio. h> int main () {int N, U, D, I, T; while (scanf ("% d", & N, & U, & D )! = EOF) {If (0 = N & 0 = u & 0 = d) break; If (n <= u) {T = 1 ;} else {for (I = 1; I ++) // here I starts from 0, so you do not need to list the first minute separately, every minute is the same, and so on. If (n <= (u-d) * I + u) break; t = 2 * I + 1;} printf ("% d \ n", T );} return 0 ;}