Lazy frog

Lazy frog

There was once a frog who live in the depth of the unknown wells,
one day he wanted to walk out.But he was lazy, climb three meters daytime and night will fall two meters.

If given the well depth x, you calculate the number of days after the frog from the well out.

Input

Input a series of test data. Each line including a integer x (x<=1000).

Output

Output there is an integer representing the number of days required.

Sample Input

     3    2   4 

Sample Output

     1    1   2 
#include <stdio.h>
int main(void)
{
    int h;
    while(scanf("%d", &h) == 1)
    {
        int m = 0, i;
        for(i = 0; m < h; )
        {
            m += 3;
            i++;
            if(m >= h)
            {
                break;
            }
            else
            {
                m -= 2;
            }
        }
        printf("%d\n", i);
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章