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. java新手笔记12 单例

    1.单例 package com.yfs.javase; public class Singleton { //private static final Singleton single = new ...

  2. Java实战之01Struts2-02配置文件

    三.Struts2的配置文件 1.加载时机: 当应用被tomcat加载的时候,struts2的配置文件就已经被加载过了. 2.加载顺序 顺序 配置文件名 所在位置 说明 1 default.prope ...

  3. arcgisserver

    http://www.cnblogs.com/hll2008/archive/2008/11/14/1333828.html

  4. MongoDB源码分析——mongo主程序入口分析

    Edit   源码版本为MongoDB 2.6分支 mongo主程序入口分析 mongo是MongoDB提供的一个执行JavaScript脚本的客户端工具,可以用来和服务端交互,2.6版本的Mongo ...

  5. starling 中的 EventDispatcher 和 Flash中原生的 EventDispatcher

    starling 比较早之前就有开始解了,但只到最近参与一个用starling 做为框架的手游项目才真正做为一程来使用它. 项目也是刚开始搭建,在这做些笔记. 在写一个管理类时, 遇到 starlin ...

  6. Nginx中让 重写后的路径 自动增加斜线 /

    http://www.111cn.net/sys/nginx/56067.htm(参考文章) 现在有个这样的需求,在重写的url地址后,自动加斜线 / 例如 xx.com/abc/1-2  (默认ur ...

  7. jquery中的 .html(),.val().text()

    .html(),.text(),.val(),.html()用为读取和修改元素的HTML标签,包括标签内的内容.text()用来读取或修改元素的纯文本内容,去除 html 标签.val()用来读取或修 ...

  8. node.js操作mongoDB数据库

    链接数据库: var mongo=require("mongodb"); var host="localhost"; var port=mongo.Connec ...

  9. 使用css3实现文章新闻列表排行榜(数字)

    列举几个简单的文章排行榜数字效果 一:使用list-style来显示数字.圆点.字母或者图片 <style> li{width:300px; border-bottom: 1px dott ...

  10. 精通 Oracle+Python,第 1 部分:查询最佳应践

    原文链接:http://www.oracle.com/technetwork/cn/articles/dsl/mastering-oracle-python-1391323-zhs.html 在 Py ...