Climbing Worm

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

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

思路:小水题,直接暴力,不解释。

  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,u,d,t,s;
  5. while(~scanf("%d%d%d",&n,&u,&d)&&n+u+d)
  6. {
  7. s = t =;
  8. while(s<n)
  9. {
  10. t++;
  11. s += u;
  12. if(s>=n)
  13. break ;
  14. s -= d;
  15. t++;
  16. }
  17. printf("%d\n",t);
  18. }
  19. return;
  20. }

Climbing Worm的更多相关文章

  1. hdu 1049 Climbing Worm

    解题思路: 1. 两种情况,0x1:井深度小于一次跳的高度.0x2:井深度大于一次跳的高度 2.如果 属于 0x1 则一次跳出 3.否则 本次解题中直接枚举跳的次数 一直循环,直到 [每次跳的真实高度 ...

  2. 【hdoj_1049】Climbing Worm

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1049 以 上升-下降 一次为一个周期,一个周期时间为2分钟,每个周期上升距离为(u-d).先只考虑上升,再 ...

  3. ZOJ 1494 Climbing Worm 数学水题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=494 题目大意: 一只蜗牛要从爬上n英寸高的地方,他速度为u每分钟,他爬完u需要 ...

  4. HDUOJ-----Climbing Worm

    Climbing Worm Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  5. 思维体操: HDU1049Climbing Worm

    Climbing Worm Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  6. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  7. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  8. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  9. zoj1494 暴力模拟 简单数学问题

    Climbing Worm Time Limit: 2 Seconds      Memory Limit:65536 KB An inch worm is at the bottom of a we ...

随机推荐

  1. Xcode中需要熟悉的常用快捷键

    因为工作需要,笔者最近开始接触Xcode这款Mac系统下的强大的编程软件.因为个人习惯,每当接触新的软件的时候总会先去了解它的一些常用快捷键.经过多方查阅总结出以下内容,希望对刚刚接触Xcode的初学 ...

  2. 数据操作So easy-LINQ解析

    1.LINQ是什么? LINQ是Language Integrated Query的缩写,即“语言集成查询”的意思.LINQ的提出就是为了提供一种跨越各种数据源的统一的查询方式,它主要包含4个组件-- ...

  3. windows server 2003 禁止开机显示“关闭事件跟踪”

    关机事件跟踪(Shutdown   Event   Tracker)也是Windows   server   2003区别于其他工作站系统的一个设置,对于服务器来说这是一个必要的选择,但是对于工作站系 ...

  4. 01_JavaMail_03_邮件发送简单实例

    [JavaMail中的核心类] 1.Session:类似Jdbc中的Connection的作用 2.MimeMessage:邮件信息类 3.Transport:发送器,用来发送邮件 [工程截图] [具 ...

  5. EntityClient 介绍

    System.Data.EntityClient 命名空间是 实体框架的 .NET Framework 数据提供程序.EntityClient 提供程序使用存储特定的 ADO.NET 数据提供程序类和 ...

  6. Oracle的硬解析和软解析

    提到软解析(soft prase)和硬解析(hard prase),就不能不说一下Oracle对sql的处理过程.当你发出一条sql语句交付Oracle,在执行和获取结果前,Oracle对此sql将进 ...

  7. vi简单快键命令

    进入vi的命令 vi filename :打开或新建文件,并将光标置于第一行首 vi +n filename :打开文件,并将光标置于第n行首 vi + filename :打开文件,并将光标置于最后 ...

  8. a标签使用

    1.发起邮件 注意:如果mailto后面同时有多个参数的话,第一个参数必须以“?”开头,后面的参数每一个都以“&”分隔. <a href="mailto:281345774@q ...

  9. React组件一

    <div id='test'></div> <script type='text/babel'> var Zu=React.createClass({ return ...

  10. js 的基础知识变量

    什么是变量? 变是一个存储和释放我的数据! 我们用var关键字来声名变量,声名多个变量时用逗号来隔开 在变量没有赋值之前,显示是一个未定义的变量! <script> var a; var ...