Climbing Worm

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

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,t,s;
while(scanf("%d%d%d",&n,&u,&d),n+u+d)
{
t=; s=;
while(){ s+=u;
if(s<n) {
s-=d; t+=; }
else if(s>=n){
t++; break; }
}
printf("%d\n",t);
}
return ;
}

HDUOJ-----Climbing Worm的更多相关文章

  1. Climbing Worm

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

  2. hdu 1049 Climbing Worm

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

  3. 【hdoj_1049】Climbing Worm

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

  4. ZOJ 1494 Climbing Worm 数学水题

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

  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. Maven镜像更换为阿里云中央仓库

    前言 maven仓库默认在国外,使用难免很慢,尤其是下载依赖的时候,换为国内镜像,让你感受飞一般的感觉.国内支持maven镜像的有阿里云,开源中国等,这里换为阿里云的. 更换 修改maven配置文件s ...

  2. 遛老虎网 http://6laohu.com/

    遛老虎网 http://6laohu.com/

  3. AngulerJS学习(五)按需动态载入文件

    在此之前我么年首先要先了解几个东西: $q 简单介绍: $q:主要解决的是异步编程的问题,是指描写叙述通过一个承诺行为与对象代表的异步运行的行动结果的交互.可能会也可能不会再不论什么时候完毕. 我们通 ...

  4. 我的四轴专用PID参数整定方法及原理---超长文慎入(转)

    给四轴调了好久的PID,总算是调好了,现分享PID参数整定的心得给大家,还请大家喷的时候手下留情. 首先说明一下,这篇文章的主旨并不是直接教你怎么调,而是告诉你这么调有什么道理,还要告诉大家为什么'只 ...

  5. 迁移Windows下的MySQL时字符乱码问题

    我们常常会直接复制一份MySQL的Data文件夹到新的环境下,正常情况下重新启动MySQL就可以使用.但有时也会遇到些问题: 1.程序訪问时提示找不到表,实际表已经存在 这样的情况是因为数据库全部者可 ...

  6. @SuppressLint("NewApi")和@TargetApi()的区别

    在Android代码中,我们有时会使用比我们在AndroidManifest中设置的android:minSdkVersion版本更高的方法,此时编译器会提示警告, 解决方法是在方法上加上@Suppr ...

  7. Solidworks如何把装配体做成单个零件

    先把装配体另存为IGS格式   再把IGS打开之后另存为SLDPRT格式(打开IGS需要比较长的时间,中途会弹出提示,而且IGS文件体积也比较大)   另存为SLDPRT之后体积就很小了       ...

  8. android中使用spinner组件,以key,value的方式

    接着上一篇文章的内容:android中使用spinner组件 稍做修改,以key,value的方式,在实际使用中,经常需要获取的值并不一定跟显示的内容一致. 需要先添加一个对象类,用来描述key,va ...

  9. ZH奶酪:Python中range和xrange的区别

    range    函数说明:range([start,] stop[, step]),根据start与stop指定的范围以及step设定的步长,生成一个序列.range示例: >>> ...

  10. Postgresql中的数据类型大全

    一.数值类型: 下面是PostgreSQL所支持的数值类型的列表和简单说明: 名字 存储空间 描述 范围 smallint 2 字节 小范围整数 -32768 到 +32767 integer 4 字 ...