PTA

7-46 爬动的蠕虫

 #include<stdio.h>
int main() {
int N,U,D,R,T=;
scanf("%d%d%d",&N,&U,&D);
R = N-U;
if(R<=) T=;
else {
T = R/(U-D)*+;
if(R%(U-D)) T+=;
}
printf("%d",T);
}

分析:

1、首先判断R=N-U是否大于0,若小于0则一分钟即可爬出

2、再计算R包含几个U-D(以两分钟为一周期,则在累计距离大于R前不可能爬出,因为即使累计距离达到了R也要再爬一次才能爬出)

3、如果R不能整除U-D,则还需在爬一个周期,所以T+2

PTA——蠕虫爬井的更多相关文章

  1. HDU 1049(蠕虫爬井 **)

    题意是一只虫子在深度为 n 的井中,每分钟向上爬 u 单位,下一分钟会下滑 d 单位,问几分钟能爬出井. 本人是直接模拟的,这篇博客的分析比较好一些,应当学习这种分析问题的思路:http://www. ...

  2. HDOJ 1302(UVa 573) The Snail(蜗牛爬井)

    Problem Description A snail is at the bottom of a 6-foot well and wants to climb to the top. The sna ...

  3. poj1563---蜗牛爬井

    #include <stdio.h> #include <stdlib.h> int main() { int dayTh; float Udis,currentHeight, ...

  4. c语言l博客作业08

    问题 答案 这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/CST2019-2/homework/8655 我在 ...

  5. TCL语言笔记:TCL过程控制练习

    1.青蛙爬井 for {set day 1;set cur 7} {$cur<77} {incr cur 2 ;incr day } { } puts $day 2.求1加到100 proc g ...

  6. 573 The Snail(蜗牛)

      The Snail  A snail is at the bottom of a 6-foot well and wants to climb to the top. The snail can ...

  7. 少儿编程|Scratch编程教程系列合集,总有一款适合你

    如果觉得资源不错,友情转发,贵在分享!!! 少儿编程Scratch: 少儿编程Scratch第一讲:Scratch完美的初体验少儿编程Scratch第二讲:奇妙的接球小游戏少儿编程Scratch第三讲 ...

  8. Python爬取CSDN博客文章

    0 url :http://blog.csdn.net/youyou1543724847/article/details/52818339Redis一点基础的东西目录 1.基础底层数据结构 2.win ...

  9. ASP.NET网络爬虫小研究 HtmlAgilityPack基础,爬取数据保存在数据库中再显示再自己的网页中

    1.什么是网络爬虫 关于爬虫百度百科这样定义的:网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本.另外一些 ...

随机推荐

  1. 分析hello1项目里面的web.xml

    在example目录下的web\jsf\hello1\target\hello1\WEB-INF路径里可以找到hello1的web.xml <?xml version="1.0&quo ...

  2. Lintcode481-Binary Tree Leaf Sum-Easy

    481. Binary Tree Leaf Sum Given a binary tree, calculate the sum of leaves. Example Example 1: Input ...

  3. _pvp

    comment 备注 zone 区域ID,.gps第二个参数 area 地域ID,.gps第三个参数 type 区域类型(保持原状.安全区.自由PVP.自由PVP - 禁止组队.自定义阵营(_fact ...

  4. Java GC机制中Minor GC/Full GC

    Minor GC Young GC Full GC Major GC https://blog.csdn.net/chenleixing/article/details/46706039 内存划分为 ...

  5. AngularJS服务及注入--Provider

    Provider简介 在AngularJS中,app中的大多数对象通过injector服务初始化和连接在一起. Injector创建两种类型的对象,service对象和特别对象. Service对象由 ...

  6. 7.6 GRASP原则六: 多态 Polymorphism

    GRASP原则六: 多态 Polymorphism  How to handle alternative behaviors based on type 如何处理依据类型不同而有 不同行为的一类需求 ...

  7. C# 关键字this用法

    1.this代表当前类的实例对象 public class Test { public string Name{get;set;} public void TestChange(string strN ...

  8. 『TensorFlow』网络操作API_中_损失函数及分类器

    一.误差值 度量两个张量或者一个张量和零之间的损失误差,这个可用于在一个回归任务或者用于正则的目的(权重衰减). l2_loss tf.nn.l2_loss(t, name=None) 解释:这个函数 ...

  9. weex playGround 扫码空白问题

    首先安装 weex debug 用 weex debug调试可以看到报错 我做的demo扫码扫不出来  是因为:class的原因 weex中:class只支持数组形式  或者  换成:style就可以 ...

  10. Linux 安装 ffmpeg

    在安装ffmpeg之前,需要先安装一些必需组件.包括但不限于以下组件(有的系统里面可能已经安装过) 首先在根目录下创建:ffmpeg_sources 1.Yasm sudo apt-get insta ...