//爬动的蠕虫 张景敏 2021.1.23
#include<stdio.h>
main()
{
int n,u,d,t=1,x=0;
scanf("%d%d%d",&n,&u,&d);
while(x<n)
{
if((t+2)%2==1)
x+=u; //前进
else x–; //休息
t++;
}
printf("%d",t-1); //t为时间加1
}
一条蠕虫长1寸,在一口深为N寸的井的底部。已知蠕虫每1分钟可以向上爬U寸,但必须休息1分钟才能接着往上爬。在休息的过程中,蠕虫又下滑了D寸。就这样,上爬和下滑重复进行。请问,蠕虫需要多长时间才能爬出井
最新推荐文章于 2025-03-06 15:36:30 发布