ZOJ Problem Set–1494 Climbing Worm

Time Limit: 2 Seconds      Memory Limit: 65536 KB


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


Source: East Central North America 2002

#include<iostream>
using namespace std;
int main()
{
  int n, u, d;
  while(cin>>n>>u>>d && n)
  {
    int upInches = 0;
    int minutes = 0;
    while(upInches < n)
    {
      minutes++;
      upInches += u;
      if(upInches >= n)
        break;
      upInches -= d;
      minutes++;
    }
    cout<<minutes<<endl;
  }
}

转载于:https://www.cnblogs.com/malloc/archive/2012/03/30/2425506.html

【数据集3】高分辨率统计降尺度日值数据集NEX-GDDP的介绍与下载方法 对NEX-GDDP数据集进行介绍和下载说明 阅读详情

相关推荐

Tomcat启动过程中cmd窗口(控制台)中文乱码的问题

tomcat启动时,启动过程日志中文乱码的处理方法。

寻码启示 1953

ZOJ 1494 Climbing Worm 数学水题

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=494 题目大意: 一只蜗牛要从爬上n英寸高的地方,他速度为u每分钟,他爬完u需要休息1分钟,且他休息时下滑d英寸,问他什么时候爬出去。 吐槽: 小学的数学题编程了编程题,简直丧心病狂。 思路: 数据量小直接模拟即可。 也可以用数学推导 模拟板: #inc...

xidajiancun 185

大数据应用技术实验报告一 Hadoop三种模式安装配置

JDK+Hadoop安装配置、单机模式配置 以下操作在SecureCRT里面完成 1.关闭防火墙 firewall-cmd --state 显示防火墙状态running/not running systemctl stop firewalld 临时关闭防火墙,每次开机重新开启防火墙 systemctl disable firewalld 禁止防火墙服务。 2.传输JDK和HADOOP压缩包 Sec...

Ruthless_Childe的博客 3098

HDU 1049 Climbing Worm

 水题一道~ Problem DescriptionAn 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

Czy 1221

Innovus时钟树综合CTS实战:从原理到signoff的完整指南

时钟树综合(CTS)是数字后端实现中保障同步电路时序收敛的核心环节,其本质是在物理层面构建低偏斜、可控延迟的全局时钟分发网络。它基于静态时序分析(STA)原理,通过平衡clock skew、insertion delay、transition time与功耗面积等多维约束,对抗工艺电压温度(PVT)变异带来的时序不确定性。技术价值在于支撑GHz级高频芯片的setup/hold签核,广泛应用于CPU、GPU、AI加速器等复杂SoC的Innovus后端流程。本文聚焦CTS在Innovus工具链中的工程落地,覆盖

weixin_28523493的博客 227

YOLO11-pose关键点检测:训练实战篇 | 自己数据集从labelme标注到生成yolo格式的关键点数据以及训练教程

教会你如何用自己的数据集转换成对应格式的数据集以及如何训练YOLO11-pose关键点检测

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 5436

HUD 1049 Climbing Worm

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches e

跟随内心的渴望 400

嵌入式工程师成长之路(2)——电路设计

为什么你的电源模块总是发热炸机?DC/DC和LDO选型的“潜规则”你踩坑了吗? LM2596降压芯片用错电容导致输出振荡?LED恒流驱动设计让灯珠寿命缩水50%?24V转12V方案成本超预算被老板狂喷?——这些血泪教训,谁能懂得!

云轩阁 13万+

Climbing Worm(模拟)

题干 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.

qq_51480701的博客 300

CMake入门教程【基础篇】CMake+Visual Studio2022构建C++项目

CMake+Visual Studio2022搭建C++环境

小鱼酱的博客 4975

planning模块(6)-参考线的平滑(二次规划)

上一篇已经介绍了采样点生成锚点数据的过程,并且将所有采样点生成的锚点数据设置到了平滑器中.接下来继续介绍使用二次规划平滑参考线的算法过程.从锚点数据中提取坐标存入raw_point2d,提取横向边界存入anchorpoints_lateralbound,将起点和终点的横向边界设置为0,防止车在起点和终点位置偏离车道中心线.

让复杂的问题变得更容易理解 792

1.2.1Climbing Worm(附翻译)

Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5750 AcceptedSubmission(s): 3389 Problem DescriptionAn inch worm is at the bottom of a well ninches...

zhen921的博客 528

stable diffusioncontrolNet 预处理器/模型的下载及安装使用教程

首先说明,controlNet 的模型 不同于stable diffusion 模型,这一点一定要区分清楚。下面提供多个ControlNet 预处理器+ 专用模型的百度网盘下载链接,都是由群友整理贡献,但各自包含的版本不同,大家可自行选择。推荐下载紫色链接内的模型,fp16版文件更小,稍微新一些的controlnet插件还添加了对control-lora的支持(注意,要求controlnet插件的版本比12月16号新(1.1.423以上)才能正常识别),推荐下载;

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 3395

Climbing Worm hdu-1049 C++

题目链接 思路 : n既是井深度,也是蠕虫离井的顶部长度。 向上爬->n减小 休息滑落->n增加 "当n小于等于0时,即为成功爬出。" 时间初始设为1,先判断向上爬一次后n是否小于等于0,如果是:结束循环,输出结果; 否则:时间+2(n>0:向上爬没到顶,接下来又休息滑落),继续循环。 #include<iostream> using namespace std; int main() { int n, u, d; int i; while (cin&

随缘博客 187

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

Climbing Worm————攀缘蠕虫

    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 in...

一个和代码打交道の小孩 1511

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Climbing Worm

Climbing Worm Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 24948 Accepted Submission(s): 17042 Problem Description An inch worm is at the...

NJU phd 在读。 604

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

HDU 1049-Climbing Worm

题目链接题目分析题意一个毛毛虫在n英尺深的井里,它每分钟向上爬u英尺,然后休息1分钟,在休息的过程中向下滑落d英尺,重复上述过程,求爬出井共需要多久。思路向上爬的高度大于或等于井的高度时候的时间即为所求。代码#include<stdio.h> #define MAX 300 int main(){ //freopen("TXC.txt","r",stdin); int n,u,d;

XuKathy的博客 590

HDU1049

HDU1049 Climbing Worm 一只蠕虫在深n英寸的井中,它每分钟会向上爬u英寸,然后它会休息1分钟并且下滑d英寸,现在要求它要多少分钟能到达进口(它就算刚到井口然后会下滑,也算它到达井口)。我们把不足1分钟的时间也算是1分钟。 输入:包含多组实例。每行代表一个实例,包括3个正整数,n,u 和 d。d 输出:对于每个实例,输出蠕虫爬到井口所需要的整数分钟时间。 分析:蠕虫到达

code 1620

Problem A: Worm!!! -- 信息杯班级对抗赛

Problem A: Worm!!! Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 165  Solved: 81 [Submit][Status][Web Board] Description 一个虫子在n单位长度的井下面,每分钟他可以走u单位长度,但是之后他要休息一分钟,并且在休息的时候他会下滑d单位长度,那么请你计算一下它需要

lz1041414957的专栏 836

Ms05039蠕虫的VC实现

文章作者:张戈(nickchang)信息来源:邪恶八进制信息安全团队(www.eviloctal.com)今年8月的新蠕虫狙击波利用了ms05039 PnP服务漏洞, 因为ms05039的exploit在网上是公开的,请见http://www.eviloctal.com/forum/htm_data/10/0508/13433.html, 可以利用这个exploit得到对方主机(win2k)的sh

4754

HDU-1049-Climbing Worm(C++ && 编程初学者的题......)

Climbing Worm Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14196    Accepted Submission(s): 9560 Problem Description An inch wor

保持对编程的热情! 1188

ACM--虫子爬井--模拟--HDOJ 1049--Climbing Worm--水

HDOJ题目地址:传送门 Climbing Worm Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 16407    Accepted Submission(s): 11180 Problem

戎码人生 1915

杭电 hdu ACM 1049 Climbing Worm

水题#include using namespace std; int cnt, n, u, d; void GreedySelector() { int sum = 0; cnt = 0; while(1) { sum += u; ++cnt; if( sum >= n )

panyanyany(飞雨幻沙) 1851

杭电ACM 1409Climbing Worm----20140801

#include int main() {     int n,u,d,s,s1;     while(scanf("%d%d%d",&n,&u,&d)!=EOF&&!(n==0&&u==0&&d==0))     {          s=0;s1=0;          while(1)          {              s+=u;             

lanxuepiaoling的专栏 388

【杭电ACM】1.2.2 Climbing Worm

【杭电ACM】1.2.2 Climbing Worm http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1&sectionid=2&problemid=4 1 #include <iostream> 2 using namespace std; 3 4 int main()...

weixin_34283445的博客 155

杭电科大ACM:Climbing 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 restin

weixin_45880057的博客 352
上一篇: ZOJ Problem Set–1292 Integer Inquiry
下一篇: 好久不见
dcl67283
博客等级 码龄12年 2粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值