CODE:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std;
int n, u, d;
int get_time()
{
int i;
int x = u-d;
int cur = 0;
for(i = 1; i <= n/x; i++)
{
cur = i*x;
if(cur >= n-u && cur < n) //还差一步到顶点
{
break;
}
}
cur = 2*i + 1; //包括上升和下降的时间,所以乘以2
return cur;
}
int main()
{
while(~scanf("%d%d%d", &n, &u, &d))
{
if(n == 0 && u == 0 && d == 0) break;
if(u >= n)
{
printf("1\n");
}
else if(d == 0)
{
if(n%u == 0)
{
printf("%d\n", n/u);
}
else
{
printf("%d\n", n/u+1);
}
}
else
{
printf("%d\n", get_time());
}
}
return 0;
}
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std;
int n, u, d;
int get_time()
{
int i;
int x = u-d;
int cur = 0;
for(i = 1; i <= n/x; i++)
{
cur = i*x;
if(cur >= n-u && cur < n) //还差一步到顶点
{
break;
}
}
cur = 2*i + 1; //包括上升和下降的时间,所以乘以2
return cur;
}
int main()
{
while(~scanf("%d%d%d", &n, &u, &d))
{
if(n == 0 && u == 0 && d == 0) break;
if(u >= n)
{
printf("1\n");
}
else if(d == 0)
{
if(n%u == 0)
{
printf("%d\n", n/u);
}
else
{
printf("%d\n", n/u+1);
}
}
else
{
printf("%d\n", get_time());
}
}
return 0;
}