#include<iostream>
using namespace std;
int main()
{
int n,u,d;//井深 爬的高度 掉落的高度
int s;
int j=0;//计时
cin>>n>>u>>d;
if(d>u)//首先判断掉落的高度大于每次上爬的高就不用继续下一步了
{
cout<<"The worm can't escapes from well."<<endl;
return 0;
}
while(s<n)//当前爬高小于井深时
{
s=s+u;//爬的高度
j++;//计时一次
if(s<n)//当前爬了还小于井深的情况下
{
s=s-d;
j++;
}
}
cout<<j<<endl;
return 0;
}
爬动的蠕虫 c++
于 2023-11-25 15:02:55 首次发布