5-17 爬動的蠕蟲 (15分)


#include <iostream>
#include <string.h>
#include <map>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
    int N,U,D,time=0,H=0;
    scanf("%d%d%d",&N,&U,&D);
    while(1)
    {
        H+=U;
        time++;
        if(H>=N)break;
        H-=D;
        time++;

    }
    printf("%d\n",time);
    return 0;
}


發佈了73 篇原創文章 · 獲贊 25 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章