(HDOJ 1049)Climbing Worm


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

 AC code:

 #include<stdio.h>

int  main()
{
     
int  n,u,d;
     
int  count,i,s;
     
while (scanf( " %d %d %d " , & n, & u, & d) && n)
     {
         
if (n <= u) s = 1 ;
         
else
         {
             
for (i = 1 ; ; i ++ )
             {
                 
if (n - (u - d) * i <= u)
                 
break ;
                 }
                 count
= i;
                 s
= 2 * count + 1 ;

         }
         printf(
" %d\n " ,s);
        }
     
return   0 ;
} 

转载于:https://www.cnblogs.com/cpoint/archive/2011/04/13/2015327.html

[QMT量化交易小白入门]-二、如何用miniQMT获取沪深A股的板块列表、历史行情数据和实时行情数据 本专栏主要是介绍QMT的基础用法,常见函数,写策略的方法,也会分享一些量化交易的思路,大概会写100篇左右。QMT的相关资料较少,在使用过程中不断的摸索,遇到了一些问题,记录下来和大家一起沟通,共同进步,自己淋过雨了,希望大家都有一把伞。 阅读详情

相关推荐

INCA基础教程

以软件自带Demo为例记录INCA学习过程,主要内容包括测量与标定。

yunqianrui的博客 6万+

ZOJ 1494 Climbing Worm 数学水题

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

xidajiancun 185

从Chimera到ChimeraX:科研绘图升级指南,让你的论文配图更专业

本文详细介绍了从UCSF Chimera升级到ChimeraX的科研绘图指南,帮助研究者提升论文配图质量。ChimeraX在渲染引擎、大分子处理能力和动画功能上具有显著优势,特别适合生命科学和结构生物学领域。文章涵盖材质设置、专业配色、工作流程和期刊适配等核心技巧,助力产出出版级分子可视化图像。

weixin_33670786的博客 951

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

利用HTML+CSS设计PPT:html-to-pptx实现自动化转换与可编辑输出

在办公自动化和前端开发领域,将网页技术应用于文档生成是一个重要的技术方向。其核心原理在于通过解析HTML/CSS的结构与样式,将其映射为目标文档的原生对象模型。这项技术的价值在于,它能够将Web技术栈强大的布局与样式能力(如Flexbox、CSS Grid)与办公软件(如Microsoft PowerPoint)的广泛兼容性和可编辑性相结合。在实际应用场景中,这种技术特别适合需要快速生成兼具设计感与实用性的演示文稿,例如数据报告、产品发布和营销材料。本文探讨的html-to-pptx项目正是这一思路的工程实

weixin_30652491的博客 492

2023-2024深度学习框架之争——选pytorch还是tensorflow?

深度学习是人工智能领域的一个重要分支,它利用多层神经网络来模拟人类的学习和推理能力,解决各种复杂的问题,如图像识别、自然语言处理、语音识别、推荐系统等。深度学习框架是一种软件工具,它提供了构建、训练、测试和部署深度学习模型的便利,使得开发者和研究者可以更高效地进行深度学习的开发和应用。目前,市场上有许多不同的深度学习框架,如PyTorch、TensorFlow、Keras、MXNet、Caffe2等,它们各有优劣,适用于不同的场景和需求。

flchen_nchu的博客 6767

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

跟随内心的渴望 399

2025华为od机试真题B卷【版本管理】Python实现

在 软件版本管理中,版本号由点分割的数字组成,例如 1.2.3 和 2.8。现在,你需要编写一个函数,计算两个版本号之间的可用版本号个数。这里的可用版本号指的是所有满足 version1<x<version2的版本号x的个数。若 version1 >=version2 返回0.,

MISAYAONE的博客 651

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

【Unity实战篇 】| 游戏中实现镂空遮罩效果【矩形、圆形镂空遮罩】

本文来写一下怎样在Unity中完成一个 镂空遮罩 的效果。 镂空遮罩 比较常用的有两种:矩形镂空遮罩、圆形镂空遮罩。 镂空遮罩 在游戏中常被当做新手引导必备的内容,可以给玩家更多不一样的体验。 下面就一起来看一下怎样做出这种效果吧!

努力前行,总会成为自己心中的那道光 1万+

34、木材在家具制造中的应用

本文详细探讨了木材在家具制造中的应用,从木材的选择、加工技术到设计创新和表面处理等方面进行了全面解析,并结合实际案例分析木材家具的市场趋势与未来发展。文章强调了木材家具在功能性、智能化和环保性方面的潜力,展示了其在现代家居生活中的重要地位。

flink9streamer的博客 245

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

把 SAP BTP Destination 写进 MTA:一段 com.sap.application.content 配置背后的部署编排学

MTA内容模块解析:SAP BTP中的声明式部署机制 本文详细解析了mta.yaml中com.sap.application.content模块在SAP BTP云环境中的作用。该模块通过声明式配置实现内容投递,无需编译或部署代码。核心功能包括: Destination创建:通过content-target:true标识将配置投递到Destination服务 HTML5应用部署:将静态资源投递到HTML5 Application Repository 安全集成:配置XSUAA服务实现OAuth2用户令牌交换

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 174

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

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

【hdoj_1049】Climbing Worm

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1049 以 上升-下降 一次为一个周期,一个周期时间为2分钟,每个周期上升距离为(u-d)。先只考虑上升,再只考虑下降。先上升n/u次,再下降n/u次,这样保证不会超过井口,这样上升和下降各n/u次之后离井口距离为 n-(u-d)*(n/u),用时n/u分钟。最后一定会出现这样的情况,离井口的距离 用D

tensory的博客 672

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

hdoj 1049 Climbing Worm

<br />hdoj 1049  Climbing Worm<br /> #include<iostream> using namespace std; int n,u,d; int main(){ int n; while(cin>>n&&n!=0){ cin>>u>>d; int ti=0; int len=0; while(len<n){ ti++; l

CandyLien 549

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

hdoj 1049 Climbing Worm

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

世界很大 477

HDOJ1049 Climbing Worm

Climbing Worm Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 20524    Accepted Submission(s): 14052 Problem Description An inch worm i

BarryLee的博客 310

[HDOJ 1049] Climbing Worm (基础题)

题目窗口:---->http://acm.hdu.edu.cn/showproblem.php?pid=1049 基础题,基本没挑战性。不过看着一次性AC,心里特滋润,嘿嘿。 5471645 2012-03-05 13:23:55 Accepted 1049 0MS 284K 363 B C++ ajioy #include using n

AJIOY的专栏 1090

hdoj 1049 Climbing Worm【贪心】

 Climbing Worm Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14519    Accepted Submission(s): 9817 Sample Input 10 2 1 20 3 1 0 0 0

nailnehc的博客 419

HDOJ--1049--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

猩猩是个好程序员的博客 203

hdoj1049 Climbing Worm

Climbing Worm<br />Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)<br />Total Submission(s): 5203    Accepted Submission(s): 3145<br /><br />Problem DescriptionAn inch worm is at the bottom of a well n inches deep. It ha

独行闹市无人问,青灯剑影响素琴 804

hdoj 1049 Climbing Worm 【水题】

题目大意:一只蜗牛在深为n的井中, 每分钟往上爬u, 但是之后要歇一分钟,在这歇的一分钟中里下降d, 问什么时候蜗牛能爬出来,n为0的时候也算是出来了 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1049 水题直接上代码: #include int main() { int n, u, d, ans; while(scanf("%d%d%

shengweisong 872

HDOJ 1049 Climbing Worm

HDACM 1049 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ in

whale blog 247

HDOJ 1049 Climbing Worm

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

淡定的小鱼 699
上一篇: (HDOJ 1076)An Easy Task
下一篇: (HDOJ 2000)ASCII码排序
aeg84268
博客等级 码龄11年 14粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值