Climbing Worm HDU - 1049 (简单模拟题)

#include <stdio.h>

int main()
{
    int n, u, d;
    while(~scanf("%d %d %d", &n, &u, &d))
    {
        if(n == 0)
            break;
        int t = 0;
        while(1)
        {
            n -= u;
            t++;
            if(n <= 0)     //在这个地方跳出循环 
                break;
            n += d;
            t++;
        }
        printf("%d\n", t);    
    }
    return 0;    

猜你喜欢

转载自blog.csdn.net/mch2869253130/article/details/86136150