由于输入数据规模不大,用简单模拟即可

代码如下:

 

#include<stdio.h>
int main()
{
    int d,u,n,x,time;

    while(scanf("%d %d %d",&n,&u,&d),n)
    {    x=0;time=0;
        while(1)
        {
            x+=u;time++;if(x>=n) break;
            x-=d;time++;
        }
        printf("%d\n",time);
    }
    return 0;
}

 

用到了while(1)语句。

相关文章:

  • 2022-12-23
  • 2021-08-01
  • 2021-08-25
  • 2022-01-01
  • 2021-12-15
  • 2021-06-03
  • 2022-12-23
猜你喜欢
  • 2021-10-23
  • 2022-02-15
  • 2021-12-23
  • 2022-02-25
  • 2021-12-10
相关资源
相似解决方案