题目大意:虫子在墙底往上爬,1分钟爬u,休息1分钟,掉下d,墙高n。问虫子爬出去要多少时间(虫子上爬的时候到顶部不足一分钟按一分钟计算)?
#include <stdio.h>
int main()
{
int high,time,n,u,d;
while(scanf("%d %d %d",&n,&u,&d)!=EOF&&(n||u||d))
{
high=time=0;
while(high<n)
{
high+=u;
time++;
if(high>=n)
break;
high-=d;
time++;
}
printf("%d\n",time);
}
return 0;
}