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. VS2015预览版中的C#6.0 新功能(三)

    VS2015预览版中的C#6.0 新功能(一) VS2015预览版中的C#6.0 新功能(二) Using static 使用using StaticClass,你可以访问StaticClass类里的 ...

  2. Memcache入门知识

    Memcache适合做缓存,是一款管理内存的很小的软件,实现对内存数据的管理,一般我们用memcache存储临时数据,因为内存不能储存永久化的数据,内存里面的数据,断电就消失了. memcache可以 ...

  3. centos 6.4从源码安装mysql 5.6笔记

    上周在安装mysql时遇到了些许麻烦,今天整理下. 在代码目录建立obj文件夹. 在obj目录下,执行cmake .. -DXXX  // XXX表示一些参数,详见http://dev.mysql.c ...

  4. java poi 合并单元格后边框问题

    在项目中用poi合并单元格,但发现边框会有不显示的问题. 在网上搜集了答案,来记录一下. 解决方法: 将每个没用到的单元格都设空值. 例如: HSSFCell cell = row.createCel ...

  5. jquery.ajax和Ajax 获取数据

    前几天接触了jquery 看到里面ajax的部分,自己也不是很懂,然后有重复看了即便,然后写了一个小功能,分享下...我刚学的.有错误的请指教. 验证用户名是否存在 在checkname_jqajax ...

  6. css让图片居中显示在手机屏幕上

    直接上代码了 <div class="showpic"> <span></span> <img src="" alt= ...

  7. [C++程序设计]用数组名作函数参数

    1. 用数组元素作函数实参 #include <iostream> using namespace std; int max_value(int x, int max) { return ...

  8. [汇编语言]-第十章 ret,retf,call指令

    1- ret 相当于 pop IP;用栈中数据,修改IP内容.从而实现近转移. 执行后(IP)=0, CS:IP指向代码段的第一条指令. assume cs:code stack segment db ...

  9. Yii2.0 UrlManager

    服务器软件的配置与1.0一致即可.. 在组件中进行如下配置: 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' = ...

  10. 无法添加sql server ER图

    Database diagram support objects cannot be installed because this database does not have a valid own ...