题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1049
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1494
题意:题目大致意思是一个虫子掉在了一个n长度深的井中,然后它每分钟可以爬u长度,然后要休息一分钟,在此期间它会掉下d长度,问最终爬出井需要多久。
代码:
#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,u,d;
while(scanf("%d %d %d",&n,&u,&d) && (n!=0 && u!=0 && d!=0))
{
int count=0;
while(n>0)
{
n=n-u;
count++;
if(n<=0)
break;
n=n+d;
count++;
}
printf("%d\n",count);
}
return 0;
}