HDU 1049 模拟
2016-05-28 16:56
302 查看
HDU 1049
Climbing Worm
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16415 Accepted Submission(s): 11185
[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
[align=left]Source[/align]
East Central North America 2002
[align=left]Recommend[/align]
We have carefully selected several similar problems for you: 1005 1108 1071 1061 1170
刷水题吃枣药丸系列
模拟法(数据量大时TLE)
#include <iostream> using namespace std; int main() { int dis,x,y; while(cin>>dis>>x>>y) { if(dis==0&&x==0&&y==0) break; int day=0; while(1) { dis-=x; day++; if(dis<=0) break; dis+=y; day++; } cout<<day<<endl; } }
博弈思想卡关键点
#include <iostream> using namespace std; int main() { int dis,x,y; while(cin>>dis>>x>>y) { if(dis==0&&x==0&&y==0) break; dis-=x; int day=2*(dis/(x-y)); dis=dis%(x-y); dis+=x; if(dis<=x) cout<<day+1<<endl; else cout<<day+3<<endl; } }
相关文章推荐
- Tomcat Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
- eclipse 中创建maven web项目
- Oracle各后台进程简介
- 第十/十一周项目三(1)-警察和厨师
- poj 3083 Children of the Candy Corn
- 约数详细分析
- java List 排序 Collections.sort()
- java.lang.ClassNotFoundException: javax.persistence.EntityListeners
- 计算机关机操作工具实现
- Android中的图片加载
- 网络流二十四题之十四 —— 孤岛营救问题(RESCUE)
- nyoj 709 第六届河南省大学生程序设计竞赛A
- 第1章 学会提出问题
- 关于“找不到附属汇编 Microsoft.VC90.CRT,上一个错误是 参照的汇编没有安装在系统上。”的解决
- Feature分支
- 关于“找不到附属汇编 Microsoft.VC90.CRT,上一个错误是 参照的汇编没有安装在系统上。”的解决
- 包含min函数的栈
- 设置一个POJO的某个属性的默认值
- 字符串操作函数
- JAVA三大框架SSH的各自作用