haoj Climbing Worm 【水题】
2015-11-01 16:02
369 查看
Climbing Worm
[b]Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14959 Accepted Submission(s): 10137
[/b]
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
10 2 1 20 3 1 0 0 0
[align=left]Sample Output[/align]
17 19代码:[code]#include<cstdio> #include<cstring> int aa,bb; int main() { int h,w,c; while(scanf("%d%d%d",&h,&w,&c)!=EOF) { if(h==0&&w==0&&c==0) break; int aa=1; h-=w; while(h>0) { h-=w; aa++; h+=c; aa++; } printf("%d\n",aa); } return 0; }
[/code]
相关文章推荐
- rs485特性、传输距离、接口防雷击、终端匹配电阻等分析
- java synchronized详解
- Oracle 12C -- 统一启动/关闭PDBs
- Linux系统用户与用户组介绍
- SQL的四种连接-左外连接、右外连接、内连接、全连接
- spring 与设计模式(创建型)之Builder模式
- uva401 Palindromes 字符串,模拟
- iOS nslog 使用 十六进制输出
- 对于zendframework2的路由配置的说明
- 重定向
- 接口返回值规则
- c语言之sizeof 与 strlen理解
- 树的子结构
- [HDOJ4006]The kth great number
- 如何提高工作效率,读《暗时间》总结
- java 为什么wait(),notify(),notifyAll()必须在同步方法/代码块中调用?
- FormBorderStyle设为None,移动Winform窗口的两种方法
- poj--2001--Shortest Prefixes(字典树)
- 操作系统与网络实现 之六
- 八秒手机编辑器