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 ...
随机推荐
- jQuery 清除div内容
$.ajax({ url: "SearchSN.aspx", data: "SN=" + $("#txtS ...
- HDU 3294 (Manacher) Girls' research
变形的求最大回文子串,要求输出两个端点. 我觉得把'b'定义为真正的'a'是件很无聊的事,因为这并不会影响到最大回文子串的长度和位置,只是在输出的时候设置了一些不必要的障碍. 另外要注意一下原字符串s ...
- 51nod1257 背包问题 V3
分数规划经典.开始精度1e-3/1e-4都不行,1e-5就A了 #include<cstdio> #include<cstring> #include<cctype> ...
- memcached内存管理及key value长度限制
1)什么是内存碎片?内存是大小有限的资源.例如把内存比作一张小床,来了一个小伙伴,可以睡下,再来一个小伙伴也能睡下.现在两个人了,他们点了差不多的大小的位置(资源),位置还有剩下.然后再来一个小胖子, ...
- 菜鸟学习笔记4——jquery事件
方法 描述 bind() 向匹配元素附加一个或更多事件处理器 blur() 触发.或将函数绑定到指定元素的 blur 事件 change() 触发.或将函数绑定到指定元素的 change 事件 cli ...
- 【英语】Bingo口语笔记(16) - 咬舌音和咬唇音的辨读
- arcgis for android 无法加载本地jpg影像解决办法
因为jpg影像没有生成金子塔文件*.rrd 一个完整的JPG影像必须包括如下文件: K-50-96-(16).aux 辅助文件K-50-96-(16).jgw 坐标信息K-50-96-(16).j ...
- gcc-4.8.3安装,gdb-7.6安装
gdb用法: http://blog.chinaunix.net/uid-26548237-id-3435525.html gdb-7.6.tar.gz: (官网下载:http://ftp.gnu. ...
- 利用COPYDATASTRUCT传递命令行参数给驻留内存的进程(SendMessage应用)
我们知道Window进程之间通过API的SendMessage方法传递消息.但是方法参数lParam是Long型,那么如果传递一个字符串(譬如命令行参数)应该怎么办呢,甚至一个对象.结构呢.VB的发送 ...
- C# ComboBox自动完成功能的示例
先看一下关键代码: DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("VV& ...