HD1049Climbing Worm
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<iostream>
using namespace std;
int main(){
int a,b,c,d,time;
while(cin>>a>>b>>c && !(a==0 && b==0 && c==0)){
time = 0;
d = ((a-b)/(b-c))*2;
if((a-b)%(b-c)==0)
{ time = d+1;}
else
{ time = d+3;}
cout<<time<<endl;
}
return 0;
}
HD1049Climbing Worm的更多相关文章
- TOJ 1191. The Worm Turns
191. The Worm Turns Time Limit: 1.0 Seconds Memory Limit: 65536K Total Runs: 5465 Accepted Run ...
- The Happy Worm 分类: POJ 排序 2015-08-03 18:57 5人阅读 评论(0) 收藏
The Happy Worm Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 4698 Accepted: 1047 Descr ...
- ZOJ 1056 The Worm Turns
原题链接 题目大意:贪吃蛇的简化版,给出一串操作命令,求蛇的最终状态是死是活. 解法:这条蛇一共20格的长度,所以用一个20个元素的队列表示,队列的每个元素是平面的坐标.每读入一条指令,判断其是否越界 ...
- Samy XSS Worm之源码讲解
说到Web安全和XSS跨站脚本技术,几乎所有的书都会提到Samy Worm,这是在2005年感染了mySpace社交网络上百万用户的蠕虫.正如Morris蠕虫是互联网第一个蠕虫, Samy Worm则 ...
- HDU 2151 Worm
Worm Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submissi ...
- Discuz X1.5 利用添加好友处存储xss进行蠕虫worm扩散
Discuz X1.5 在添加好友的地方有处存储xss,借助此处xss跟用户交互可以进行蠕虫指数扩散. 位置在添加好友处 x完之后的效果 点击后触发 ok 借助此存储xss,我们进行worm传播,dz ...
- hdoj 2151 Worm【动态规划】
Worm Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDOJ --- 2151 Worm
Worm Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- Climbing Worm
Climbing Worm Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
随机推荐
- Android - View绘图原理总结
Android系统的视图结构的设计也采用了组合模式,即View作为所有图形的基类,Viewgroup对View继承扩展为视图容器类,由此就得到了视图部分的基本结构--树形结构 View定义了绘图的 ...
- c#调用系统资源大集合-3
public static void 打开控制面板多媒体属性音频() { Process.Start("rundll32.exe", " shell32.dll,Cont ...
- 基础组件_panel面板
面板作为承载其它内容的容器.这是构建其他组件的基础(比如:layout,tabs,accordion等).它还提供了折叠.关闭.最大化.最小化和自定义行为.面板可以很容易地嵌入到web页面的任何位置. ...
- git和其他版本控制系统的区别
所有除了Git以外的版本控制系统都使用增量存储方式来保存不同版本,而Git则在每一个commit时,保存一个整个文件的content copy,除非那个文件没有做过改动.Git和其他版本系统的主要区别 ...
- staging server, source congtrol, deply workflow using git
web项目开发中,有三个实践对于项目成功是非常重要的: 1. staging servers 2. Version control workflows 3. Tested, repeatable de ...
- python——no module named XX
加PYTHONPATH吧,新建一个系统环境变量,把你的目录复制进去即可
- Oracle安装错误ora-00922(zhuan)
Oracle安装错误ora-00922(缺少或无效选项) (2012-03-19 10:49:27) 转载▼ 标签: 杂谈 安装Oracle 11g R2的过程中,在新建数据库实例时出现了该错误, ...
- js获得鼠标的位置
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 【英语】Bingo口语笔记(64) - Beat系列
- 下载个jquery-easyui-1.3.0使用,把他导入到myeclipse10里,jquery-1.7.2.min.js报错。 错误如下, Syntax error on token "Invalid Regular Expression Options", no accurate correc
1.选中报错的jquery文件“jquery-1.2.6.min.js”.2.右键选择 MyEclipse-->Exclude From Validation .3.再右键选择 MyEclips ...