题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1049
大意为:每分钟向上爬b米,休息时每分钟下落c米。问爬a米的高度需要花费多长时间?
时间t为:经过k(0<=k)次(上爬+下滑)并加上最后x(0<x<=b)英寸的冲刺
由题意可知:a-b英寸这段距离是必须通过(上爬+下滑)的方式来走的,最后b英寸才有可能是直接上爬到达的
时间t=上取整[(a-b)/(b-c)]*2+1
而x/y的上取整=(x+y-1)/y
故t=[(a-c-1)/(b-c)]*2+1
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int a,b,c;
while(scanf("%d %d %d",&a,&b,&c)!=EOF)
{
if(a==0&&b==0&c==0)
break;
int sum=((a-c-1)/(b-c))*2+1;
printf("%d\n",sum);
}
return 0;
}