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. 关于DCLP实现的单例模式的一些想法

    关于DCLP实现的单例模式的一些想法 我之前写过单例的文章( http://www.cnblogs.com/mkdym/p/4908644.html ),但是现在又有了一些想法,不想再在原来那篇文章上 ...

  2. Linux中Firefox——Firebug插件安装及使用

    Firebug的安装方法即打开方式同httpfox Firebug使用指南: Firebug可以随时编辑页面:在HTML标签中,点击窗口上方的"inspect"命令,然后再选择页面 ...

  3. C#读写word

    操作word之前需要在COM引入Microsoft Office 12.0 Object Library(文件库可能不一样) 然后添加using Microsoft.Office.Interop.Wo ...

  4. 使用xml及java代码混合的方式来设置图形界面

    参考<疯狂android讲义>第2版2.1节 设置android的图形界面有三种方法: 1.使用纯xml文件 2.使用纯java,代码臃肿复杂,不建议使用 3.使用xml与java混合,前 ...

  5. PROCEDURE_监测系统_告警信息存储过程—产生告警信息插入告警表

    create or replace procedure proc_alarmlog(in_id   in number, --采集器编码                                 ...

  6. linux下mysql忘记root密码的解决方案

    1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态下,其他的用户也可以任意地登录 ...

  7. KEIL C51中const和code的使用

    code是KEIL C51 扩展的关键字,用code修饰的变量将会被放到CODE区里.但C语里的const关键字好像也有定义不能改变的变量的功能,这两个关键字有什么区别呢?在帮助手册里查找const, ...

  8. MVC 模型绑定

    在WebForm,获取提交表单的值一般都是Request.Form["Title"]这样的方式.在MVC中,提供了模型绑定机制.让后台获取表单或Url中的参数变得更加简单. 一.基 ...

  9. [置顶] SPL讲解(7)--Query高级篇

    SmartPersistenceLayer 2.0 之Query高级查询篇 总述 在看了前面的功能后,大家都会考虑到多表之间的查询怎么办.在这里,我想先讲一下查询在应用系统中的复杂性/重要性/可行性. ...

  10. 三 ICE开发初级研究

    http://www.acejoy.com/bbs/viewthread.php?tid=2878&extra=page%3D1 ICE开发初级研究(一) 最近一段一直在忙于工作,事情比较多, ...