Description

An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but then has to rest a minute before climbing again. During the rest, it slips down d inches. The process of climbing and resting then repeats. How long before the worm climbs out of the well? We'll always count a portion of a minute as a whole minute and if the worm just reaches the top of the well at the end of its climbing, we'll assume the worm makes it out. 
 

Input

There will be multiple problem instances. Each line will contain 3 positive integers n, u and d. These give the values mentioned in the paragraph above. Furthermore, you may assume d < u and n < 100. A value of n = 0 indicates end of output. 
 

Output

Each input instance should generate a single integer on a line, indicating the number of minutes it takes for the worm to climb out of the well. 
 

Sample Input

10 2 1 20 3 1 0 0 0
 

Sample Output

17 19

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int n,u,d;
while(scanf("%d%d%d",&n,&u,&d)&&(n||u||d))
{
if((n-u)%(u-d)==)
{
printf("%d\n",((n-u)/(u-d))*+);
}
else
{
printf("%d\n",((n-u)/(u-d))*+);
}
}
}

CDZSC_2015寒假新人(1)——基础 f的更多相关文章

  1. CDZSC_2015寒假新人(1)——基础 e

    Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever ...

  2. CDZSC_2015寒假新人(1)——基础 c

    Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the wareho ...

  3. CDZSC_2015寒假新人(1)——基础 i

    Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you mus ...

  4. CDZSC_2015寒假新人(1)——基础 h

    Description Ignatius was born in a leap year, so he want to know when he could hold his birthday par ...

  5. CDZSC_2015寒假新人(1)——基础 g

    Description Ignatius likes to write words in reverse way. Given a single line of text which is writt ...

  6. CDZSC_2015寒假新人(1)——基础 d

    Description These days, I am thinking about a question, how can I get a problem as easy as A+B? It i ...

  7. CDZSC_2015寒假新人(1)——基础 b

    Description The highest building in our city has only one elevator. A request list is made up with N ...

  8. CDZSC_2015寒假新人(1)——基础 a

    Description Contest time again! How excited it is to see balloons floating around. But to tell you a ...

  9. CDZSC_2015寒假新人(2)——数学 D

    D - D Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

随机推荐

  1. C++ 查找文件夹下的文件

    #include <string> #include <vector> #include <cstring> #include <cstdio> #in ...

  2. stretchlim函数分析

    在看imadjust代码时,看到stretchlim函数,特此分析一下,代码注释如下 function lowhigh = stretchlim(varargin) %STRETCHLIM Find ...

  3. shell script中的$*和$@

    在shell script中,$*和$@都是获取所有的命令行参数,但是这两者在使用的过程中会有细微的差别,差别主要是在有没有使用双引号,即是直接使用$*,$@,还是使用"$*",& ...

  4. yii2 去掉index.php的方法

    1.开启apache-rewrite 在Windows下,我们一般使用的是Administrator账号,所以启用这两项非常简单: 在[Apache安装目录]/conf/httpd.conf中找到 # ...

  5. 用实例一步步教你写Jquery插件

    最近Web应用程序中越来越多地用到 了JQuery等Web前端技术.这些技术框架有效地改善了用户的操作体验,同时也提高了开发人员构造丰富客户 端UI的效率.JQuery本身提供了丰富的操作,但是,有时 ...

  6. 10--动作系统(四)动作类中的reverse方法

    上一篇文章在使用持续动作过程中遇到不少问题,以获取动作类的反系动作尤为突出.所以今天把动作类找了个遍,先将大部分动作类是否实现reverse方法总结如下: T表示实现F表示没有实现. 观察可以发现带T ...

  7. ThinkPHP框架一

    1.1 框架的概念 框架其实就是可重用代码的集合,框架的代码是框架架构的代码,不是业务逻辑代码,框架代码保护类.方法.函数等等,框架代码按照一定的规则组合起来就形成了框架. 1.2 不使用框架开发的时 ...

  8. PHP自动生成前端的表单框架

    <?php /** * 为当前所在菜单项样式 * @param string $controller_name * @param string $action_name * @param str ...

  9. python之3内置容器

    所谓内置容器,就是不需要第三方模块,就可以使用的. 1.list容器,一个有序序列,类似于数组,但比数组强大很多 1.1.如何初始化list,直接一个[]即可,这是一个空的list >>& ...

  10. OSA-MAC: A MAC Protocol for Opportunistic Spectrum Access in Cognitive Radio Networks

    This full text paper was peer reviewed at the direction of IEEE Communications Society subject matte ...