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

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

#include<stdio.h>
int main()
{

int
n,u,d,t,s;
while
(~scanf("%d%d%d",&n,&u,&d)&&n+u+d)
{

s = t =;
while
(s<n)
{

t++;
s += u;
if
(s>=n)
break
;
s -= d;
t++;
}

printf("%d\n",t);
}

return
;
}

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. Activiti安装

    1.Activiti下载与简介 1.1  简介 Activiti项目是一项新的基于Apache许可的开源BPM平台,从基础开始构建,旨在提供支持新的BPMN 2.0标准,包括支持对象管理组(OMG), ...

  2. 10.21_Nutz批量插入顺序,POI,wiki持续关注,POI,SSH,数据库优先

    (1)Nutz,dao的批量插入会关注顺序吗? http://www.douban.com/group/topic/64322582/ (2)工作需要优先!!!  POI,SSH,数据库管理及plsq ...

  3. IOS 学习日志 2015-3-17

    Objective--C 一 关键字 @class 导入已有的类 id 对象类型 表示任何一个ObjC对象类型 Block 对象类型 OC中称为代码块 类似于C中的函数式指针 typedef 定义数据 ...

  4. 虚拟机环境Centos如何上网

    虚拟机环境Centos如何上网----------by ruffianfish.痞子鱼 因为我是用的虚拟机的环境,所以一切操作角度从虚拟机出发. 虚拟机环境的优点: 适合新手学习linux 永远不要怕 ...

  5. 每天一条linux命令——halt

    halt命令用来关闭正在运行的Linux操作系统.halt命令会先检测系统的runlevel,若runlevel为0或6,则关闭系统,否则即调用shutdown来关闭系统. 语法: halt(选项) ...

  6. datatables完整的增删改查

    1.需要指定datatables的ID <button class="btn btn-primary" id="newAttribute">新增证照 ...

  7. HTML 表单和表格

    1.使用表单标签 网站使用 HTML 表单可与用户进行交互,表单元素是允许用户在表单中输入内容,比如:文本框.文本域.单选框.复选框.下拉列表.按钮等等,表单可以把浏览者输入的数据传送到服务器端,这样 ...

  8. Redis的PHP操作手册(自用)

    String 类型操作 string是redis最基本的类型,而且string类型是二进制安全的.意思是redis的string可以包含任何数据.比如jpg图片或者序列化的对象 $redis-> ...

  9. 005 Python的数值类型

    005 Python的数值类型 BIF    指的是内置函数,一般不作为变量命名.如 input,while,if,else,float,等等.整型:整数.(python3.0版本把整型和长整型结合在 ...

  10. 使用WMI监控进程启动与结束

    需要添加引用System.Management 代码: static void Main(string[] args) { //创建WQL事件查询,监视进程开启 var qCreate = new W ...