贪心专题-HDU 1049
来源:互联网 发布:java微商城 编辑:程序博客网 时间:2024/06/15 14:58
Climbing Worm
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19464 Accepted Submission(s): 13232
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 120 3 10 0 0
Sample Output
1719
Source
East Central North America 2002
Recommend
We have carefully selected several similar problems for you: 1108 1071 1061 1170 1425
ac代码
#include <stdio.h>#include <string.h>#include <math.h>#include <algorithm>using namespace std;int main(){ int n,u,d; while(~scanf("%d%d%d",&n,&u,&d),n){ int tmp; tmp=ceil( ( n - u ) *1.0 / ( u - d ) )*2; // printf("tmp=%d\n",tmp); printf("%d\n",tmp+1); } return 0;}
阅读全文
0 0
- 贪心专题-HDU 1049
- 贪心专题 HDU 2111
- 贪心专题 HDU
- 贪心专题 HDU 1050
- 【贪心专题】HDU 1049 Climbing Worm (爬井趣题)
- 【贪心专题】POJ 1323 && HDU 1338 Game Prediction (贪心)
- 【贪心专题】HDU 1009 FatMouse' Trade (贪心选取)
- 贪心专题
- 贪心专题
- 贪心专题
- 【贪心专题】HDU 1050 D - Moving Tables (移桌子)
- 【贪心专题】HDU 1051 Wooden Sticks (切割木棍)
- HDU 1049(贪心)
- 【贪心专题】HDU 1257 最少拦截系统&&HDU 2111 Saving HDU (选宝贝)
- 【贪心例题专题】&贪心~越多越好哟~&
- 【贪心专题】HDU 1800 Flying to the Mars (寻找最大重复元素) && HDU 2124 Repair the Wall (贪心)
- 贪心专题16题
- 贪心专题总结
- LightOJ
- 【msp430 launchpad、RF模块】调制、解码无线信号2
- 自定义view中绘制文本居中解决方案
- 【Qt】]Qt5中文乱码
- C++之const的使用
- 贪心专题-HDU 1049
- xpath 获取当前节点的父节点,兄弟节点的方法
- Jquery和纯JS实现轮播图(二)--淡入淡出切换式
- servlet 生命周期
- 静态联编和动态联编
- cmake build时添加调试信息
- RS232和RS485认识
- jsp 页面联动菜单
- 基于redis分布式锁实现"秒杀"