Climbing Worm

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10528    Accepted Submission(s): 6970

Problem 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
 
Source
 
 
 #include <stdio.h>

 int main()
{
int n,u,d;
while(scanf("%d %d %d",&n,&u,&d),n)
{
int t;
t=(n-u)/(u-d);
if(((n-u)%(u-d))!=)
t+=;
printf("%d\n",t*+);
}
return ;
}

简单题

 

hdu_1049_Climbing Worm_201311061331的更多相关文章

随机推荐

  1. Oracle查询列重命名

    select count(*) 呼入量 from crm_cisco_call_detail

  2. 【转载】UML图示与代码对照

    一.类继承 public class Father { } public class Child : Father { } 二.接口继承 public interface IBreath { } pu ...

  3. 2.android

    ImageButton action_btn = (ImageButton) findViewById(R.id.action_btn);action_btn.setOnClickListener(n ...

  4. input的type等于mage标签引发的页面提交!

    主要原因是使用了<input type="image",而且放在了<form中. <input type="image"标签类似<inp ...

  5. [Swift通天遁地]七、数据与安全-(14)使用单元测试进行邮箱格式的验证

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  6. 对于Mobile模块化的概念认知(小白)

    最近刚刚学习了Mobile的一些基础知识,把它整理一下方便自己的学习 那什么是Mobile呢? 自己的理解是将一个项目中共同的部分抽出来,这样就形成了Mobile模块. 为什么要使用Mobile呢? ...

  7. Python/Django 下载Excel2007

    一.前提 上一篇,我写了下载Excel2003的博文,这里写下载Excel2007的博文的原因有三: 第一.Excel2003基本已经淘汰了 第二.Excel2003下载文件太大,不利于网络传输 第三 ...

  8. 传值:web.xml传递参数 即在Servlet中获取web.xml里的值

    传值:web.xml传递参数 在web.xml中的Servlet里配置多个init-param <servlet> ... <init-param> <param-nam ...

  9. vue杂记

    VUE杂记 声明式渲染 <div id="app"> {{ message }} </div> var app = new Vue({ el: '#app' ...

  10. PHP流程控制语句(if,foreach,break......)

    背景:PHP程序中,必不可少的要用到流程控制语句.这次对于流程控制语句进行一些总结. 条件控制语句和循环控制语句是两种基本的语法结构,它们都是用来控制程序执行流程.也是构成程序的主要语法基础. 一.程 ...