Elevator

Python遥感图像处理指南(2)-卫星影像分析MNDWI提取 在第一篇文章中,我们使用了我们导入的软件包中已定义的函数,如 rasterio 中的 open 和 read 以及 matplotlib 中的 imshow。现在,我们可以编写自己的函数了。函数是一段代码,它接收一些参数作为输入并返回输出(经过一些计算),可以在代码中多次重复使用,也可以被其他代码重用。在 Python 中定义一个新函数非常简单。return v在此语法示例中,arg1和arg2强制参数,应该传递给函数,否则会引发错误,而arg3是一个可选参数,如果是,则假定默认值 1从函数调用中省略。 阅读详情

题目描述
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.

For a given request list, you are to compute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not have to return to the ground floor when the requests are fulfilled.

输入
There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed.

输出
Print the total time on a single line for each test case.

样例输入
1 2
3 2 3 1
0
样例输出
17
41

题目大致就是说电梯运行过程中,向上一层6秒,向下一层4秒,在指定层数停5秒,有两个注意点就是,起始位置为0层,且要将最后一层所停的时间算在内。

#include<stdio.h>
int main()
{
    int i,j,b,p,n;
    while(scanf("%d",&n)!=EOF)
    {
        int sum=0;
        int a[101];
        if(n==0)
        break;
        else
        {
            a[0]=0;
            for(i=1;i<=n;i++)
            {
                scanf("%d",&a[i]);
                /*if(a[i]==a[i-1])
                {
                    sum+=5;
                }*/
                if(a[i]>a[i-1])
                {
                    sum+=(a[i]-a[i-1])*6+5;
                }   
                if(a[i]<a[i-1])
                {
                    sum+=(a[i-1]-a[i])*4+5;
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
 } 

以上代码如果没有/* */之间的内容,oj是通不过的,因为没有考虑到,如果下一次指定到达的层数与当层数相同的情况。不过我觉得还真不用考虑,没有人会站在5楼的电梯上,去往5楼,还要为此停5秒。

#include <stdio.h>
int main()
{
    int n;
    while (scanf("%d",&n),n)
    {
        int a,b=0,t,s=0;
        while (n--)
        {
            scanf("%d",&a);
            s+=(t=a-b)>0?t*6+5:-t*4+5;
            b=a;
        }
        printf("%d\n",s);
    }
    return 0;
}

更为简便的方法,用while (scanf(“%d”,&n),n)来结束n为0时的循环,用到了x>y?x:y的语句,在只有两种数据实现的情况下,这种语句是非常简便的。

AFSim 2.9中文手册实战指南:从安装到高级功能详解(附B站视频链接) 本文详细介绍了AFSim 2.9的安装配置、基础功能操作和高级功能应用,帮助用户快速掌握这款强大的仿真平台。从系统要求检查到多体动力学仿真,再到性能优化技巧,全面解析AFSim 2.9的使用方法,适合初学者和进阶用户参考。 阅读详情

相关推荐

SAR成像处理基本知识2——图像尺寸与回波尺寸的关系

阅读本文前,请先了解上一篇文章(SAR成像处理基本知识1——常用专用名词解释) 1. SAR图像尺寸预估方法 以C波段2m@20km的SAR图像为例,假设天线中心下视角为35° ,说明图像尺寸的估计方法。 1.1 距离向尺寸估计 地距分辨率为2m时,距离向分辨率约为1.15m,则要求信号带宽不小于130MHz,假设信号带宽为150MHz,采样率为180MHz,那么距离向分辨单元为0.833m。 地距幅宽为20km时,距离向幅宽约为20*sind(3...

爱学习的小伟的博客 4958

PAT甲级 1008 Elevator

PAT甲级 1008 Elevator The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified o...

旺崽的博客 2847

服务器测试之GPU基础汇总

GPU英文全称Graphic Processing Unit,中文翻译为“图形处理器”。一个专门的图形核心处理器。GPU是显示卡的“大脑”,决定了该显卡的档次和大部分性能,同时也是2D显示卡和3D显示卡的区别依据。可以形象的理解为90%的ALU(运算单元),5%的Control(控制单元)、5%的Cache(缓存单元)GPU的设计原理——总结为大量的简单运算。

qq_41897488的博客 2万+

用Elevator优化AV1视频播放

AOM会员Vimeo通过Elevator改善AV1解码过程中的丢帧和质量下降问题。感谢Google软件工程师姜健对本文做的技术审校。文 / Raphaël Zumer译 / 刘俊技术审校...

LiveVideoStack 2561

UE4游戏开发:GameInstance与GameMode的实战应用与避坑指南

本文深入解析了UE4中GameInstance与GameMode的核心差异与实战应用。GameInstance作为贯穿游戏进程的全局单例,负责跨关卡数据持久化与系统管理;而GameMode则定义特定关卡内的游戏规则与逻辑,随关卡加载销毁。文章通过数据存储、动态模式切换及网络游戏等场景,提供了清晰的应用指南与常见避坑方案,帮助开发者构建更健壮的UE4游戏架构。

kubernetes8ctl的博客 234

写出GD32L233/235在读写flash的区别(用于OTA功能)

在单片机里面表示 大概是 address += sizeof(uint32_t) address += sizeof(uint64_t)1.说到OTA功能,实际上 往flash 指定区域写 数据, 拷贝数据,然后 跳转, 必要时 注意单片机的偏移量。在写本文时,L233支持单字写入,而L235只有双字写入. 一个写入地址+4 一个写入地址+8。这个是 自己写的擦除一页 数据,当然可以参考 提供的demo去实现,看自己需求。接下来是 读取 双字,也就是在L235上的读取。

teleger的博客 914

杭电acm1008 Elevator

http://acm.hdu.edu.cn/showproblem.php?pid=1008 Elevator Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14982Accepted Submission(s):...

weixin_30549175的博客 154

win10删除vmware12后,重新安装失败(遗留注册表问题)解决总结

之前安装过一次VMware虚拟机,后来由于某些已遗忘原因把它卸载了,但是没有卸载完全,为以后安装留下了一些麻烦,现在根据我google很多内容总结后写下了自己的解决办法。 一些我搜的的可以用的VM12的注册码 5A02H-AU243-TZJ49-GTC7K-3C61N ZZ510-DYX47-48ERP-D6XZG-YCKU2 YV5MU-2FX5H-M841P-LZX5X-PYHX8

Jeason的博客 2万+

PAT 1008 Elevator

PAT甲级1008题Elevator (20 分)题解。 原题链接 题目: 1008Elevator(20分) The highest building in our city has only one elevator. A request list is made up withNpositive numbers. The numbers denote at which...

theStrongestPit的博客 285

计算机组成原理汉字编码与校验设计实验报告(汉字国标码转区位码实验、汉字机内码获取实验、海明编码电路设计与海明解码)

这次实验利用logisim进行设计,进行了以下这四个实验,其中分为汉字国标码转区位码实验、汉字机内码获取实验、海明编码电路设计与海明解码,实验报告分为四个部分,在这四个部分中依次对四个实验的方案设计,设计思路进行了介绍

zhang2gongzi的博客 6万+

AI在电商中的搜索优化

自拟标题 《AI技术助力电商搜索优化:深度解析一线大厂面试题及算法编程实践》 概述 随着人工智能技术的不断发展,AI在电商搜索优化中的应用日益广泛。本文将围绕“AI在电商中的搜索优化”这一主题,介绍国内头部一线大厂如阿里巴巴、百度、腾讯、字节跳动等在面试中常见的AI相关面试题和算法编程题,并提供详尽的答案解

AI天才研究院 918

solr elevator 配置

在配置solr词条置顶的功能时, 发现在requestHandler中加入elevator components后,  词条置顶功能并不生效. 最终解决方法: 发现该requestHandler中的defType=edismax, 可能其不支持elevator, 改成dismax后, elevator生效! 很诡异的是, 后面如果把defType再改回edismax, elevator同样生效

ktan123的博客 304

【科学文献计量】标准参考出版年谱(Standard RPYS)和多维参考出版年谱(Multi RPYS)

@[TOC](标准参考出版年谱(Standard RPYS)和多维参考出版年谱(Multi RPYS)) 1 标准参考出版年谱与多维参考出版年谱 1.1 标准参考出版年谱(Standard RPYS) 标准参考出版年谱(Standard Reference Publication Year Spectroscopy)是由Marx, Bornmann, Barth, and Leydesdorff(2014)和Marx and Bornmann(2014)提出的一种量化历史出版物对研究领域影响的方法。该方法通

lys_828的博客 1104

揭秘Linux内核I/O性能优化:elevator_merge_fn如何让机械硬盘速度提升300%?

你是否遇到过服务器在高负载下I/O响应迟缓的问题?机械硬盘(HDD)的物理结构导致其随机读写性能远低于固态硬盘(SSD),而Linux内核的I/O调度器正是解决这一痛点的关键技术。本文将深入解析Linux内核中负责请求排序的核心机制,特别是通过[block/elevator.c](https://link.gitcode.com/i/03097ea3bda9636ba7ef6acb661b9e40

gitblog_00679的博客 961

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

struct elevator_queue

struct elevator_queue { struct elevator_type *type; void *elevator_data; struct kobject kobj; struct mutex sysfs_lock; unsigned int registered:1; DECLARE_HASHTABLE(hash, ELV_HASH_BITS);

星空探索 610

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

第二次—C - Elevator

C - Elevator The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and

C i C i 292

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Elevator Saga 电梯调度编程游戏指南与API文档

Elevator Saga 是一款通过编程控制电梯运行的益智游戏,玩家需要使用JavaScript编写电梯调度算法,目标是高效地运送乘客。随着挑战难度的提升,只有最优化的算法才能完成所有关卡。 ## 游戏特点 - **编程实践**:通过实际编写代码来学习JavaScript编程 - **算法优化**:考验玩家对调度算法的理解和优化能力 - **渐进难度**:关卡设计由易到难,逐步提升挑战性 -

gitblog_00394的博客 907

1006-Elevator-解题报告

愿题目: Problem Description The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in

shenggeliang的博客 361

ethernaut——Elevator

用flag状态变量来控制,达到每一次调用isLastFloor方法都返回不同值的效果。

2301_78046362的博客 251

[热身题][hdoj_1008]Elevator

// hdoj_1008 Elevator 电梯 #include int main() { int n, i, time, a[100]; while(scanf("%d", &n) && n != 0) { a[0] = 0; time = 0; for(i = 1; i <= n; i ++) scanf("%d", &a[i]); for(i = 1;

我的ACM之路 1029

HDU.1008 Elevator

文章目录一、题目解读1、原题2、分类3、题意4、输入输出格式5、数据范围二、题解参考1、总体思路2、思路①(1).分析(2).AC代码三、评价与后话1、评价2、后话 一、题目解读 1、原题 HDU.1008 Elevator 2、分类 杂题、水题 3、题意 运粮的人开始在第0层,电梯上升一层需要6s、下降一层需要4s、停留运粮需要5s. 给定一个层数列表,需按照上面的顺序进行搬运,计算所需时间。 ...

God-Excious的博客 324

Elevator 开源项目使用教程

``` Elevator/ ├── README.md ├── src/ │ ├── main.py │ ├── config.py │ ├── utils/ │ │ ├── helper.py │ │ └── logger.py │ └── modules/ │ ├── elevator.py │ └── control.py └── te

gitblog_00044的博客 435

【ACM】HDU1008 Elevator 新手题前后不同的代码版本

【前言】 很久没有纯粹的写写小代码,偶然想起要回炉再来,就去HDU随便选了个最基础的题,也不记得曾经AC过;最后吃惊的发现,思路完全不一样了,代码风格啥的也有不小的变化。希望是成长了一点点吧。后面定期去做做题、保持青春的活力! 1、青年回炉 Problem :1008 ( Elevator ) Run ID Submit Time Judge Status ...

weixin_33806509的博客 317

PAT甲级 - 1008 Elevator (20 分)

题目链接:PAT甲级 - 1008 Elevator (20 分) The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop,...

316
上一篇: Rightmost Digit
下一篇: Moving Tables
Ethan_YS
博客等级 码龄10年 3粉丝 7原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值