Elevator
http://acm.hdu.edu.cn/showproblem.php?pid=1008
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 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.
Input
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.
Output
Print the total time on a single line for each test case.
Sample Input
1 2
3 2 3 1
0
Sample Output
17
41
解题思路
完全的模拟题目叙述过程。
当last-t>0时说明电梯下楼,速度按照4s计算;否则电梯上楼,按照6s计算。
电梯每次到达指定楼层停止的时间刚好是n*5。
http://acm.hdu.edu.cn/showproblem.php?pid=1008
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 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.
Input
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.
Output
Print the total time on a single line for each test case.
Sample Input
1 2
3 2 3 1
0
Sample Output
17
41
解题思路
完全的模拟题目叙述过程。
当last-t>0时说明电梯下楼,速度按照4s计算;否则电梯上楼,按照6s计算。
电梯每次到达指定楼层停止的时间刚好是n*5。
#include <stdio.h> #include <stdlib.h> int main (int argc, char const* argv[]) { int n, ans, last, distance, i, t; while (scanf("%d", &n) != EOF) { if (0 == n) break; ans = n * 5; last = 0; for (i = 0; i < n; i++) { scanf("%d", &t); distance = last - t; if (distance > 0) { ans += distance * 4; } else { ans += abs(distance) * 6; } last = t; } printf("%d\n", ans); } return 0; }
发表评论
-
fhloj1051 投票
2013-07-04 19:42 0投票 源文件: b(.bas/.c/.cpp/.pas) 输 ... -
fhloj1050 足球赛
2013-07-04 19:36 558足球赛 源文件: a(.bas/.c/.cpp/.pas) ... -
fhloj1092 五子棋
2013-07-04 12:01 665五子棋 源文件: gobang(.bas/.c/.cpp/ ... -
fhloj1091 拼单词
2013-07-04 11:53 702拼单词 源文件: words ... -
fhloj1090 21点游戏
2013-07-04 11:44 59121点游戏 源文件: poker(.bas/.c/.cpp ... -
fhloj1089 帮奶奶算帐
2013-07-04 11:17 557帮奶奶算账 源代码:bill.bas/pas 输入文件:bil ... -
hdu1019 gcd和lcm
2012-12-06 15:09 736Least Common Multiple http://a ... -
hdu1021 推理规律
2012-12-06 09:24 887Fibonacci Again http://acm.hdu ... -
hdu1001 求和
2012-12-03 22:05 720Sum Problem http://acm.hdu.edu ... -
hdu1000 A+B
2012-12-03 18:37 777A + B Problem http://acm.hdu.e ... -
hdu2035 乘方取余
2012-12-02 18:02 1036人见人爱A^B http://acm.hdu.edu.cn/ ... -
hdu2034 差集
2012-12-02 17:43 809人见人爱A-B http://acm.hdu.edu.cn/ ... -
hdu2033 时间计算
2012-12-02 16:24 854人见人爱A+B http://acm.hdu.edu.cn/ ... -
HDU1003最大连续子序列和
2012-12-01 15:08 1399Max Sum http://acm.hdu.edu.cn/ ... -
hdu2081 字符串拼接
2012-12-01 14:35 773手机短号 http://acm.hdu.edu.cn/sho ... -
poj1163 树型结构动态规划和最大路径
2012-11-30 22:05 1145The Triangle http://poj.org/pr ... -
POJ1579递归函数定义
2012-11-30 21:58 805Function Run Fun http://poj.or ... -
POJ1050 最大子矩阵
2012-11-30 11:34 1150To the Maxhttp://poj.org/proble ...
相关推荐
HUD(抬头显示系统)是将外界信息、车况信息等行车关键信息进行融合,通过视觉效果传递实现与驾驶员进行深度人机交互的一套显示系统。市场上,不同品牌及车型HUD显示的内容有着很大的差异。有些车型只显示车速信息,...
Zemax软件设计的HUD光路,抬头显示系统(Head Up Display,HUD)也称为平视显示系统。HUD技术是20世纪60 年代在光学瞄准和雷达瞄准基础上发展起来的,最早应用在战斗机上,HUD可以将重要的信息,如速度、油量、转速...
hud3001源代码
基于osg Camera 实现hud菜单。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
ios hud 提示框
hud unity3d ugui
微信小程序 HUD
一款支持支持自定义的轻量级HUD,支持垂直、水平两种样式。SVProgressHUD非常灵活,所见的部分都可根据自己的要求进行自定义,包括自义动画效果或图片,只需要实现相关协议方法。 安装使用 pod 'XNProgressHUD' ...
unity插件 HUD Navigation System最新版本 支持小地图 HUD等功能有点效率高 体积小巧。
最新版本ugui hudtext 1.41,官网同步的最新,里面包含资源及例子,值得拥有
UGUI的HUD,用法和NGUI的一样简单.
NGUI: HUD Text Copyright 漏 2012-2014 Tasharen Entertainment Version 1.11 http://www.tasharen.com/forum/index.php?topic=997.0 -------------------------------------------------- Thank you for ...
SAE J1757-2_201811 Standard - Optical System HUD for Automotive汽车光学系统HUD标准
汽车HUD光学系统.pptx
UGUI HUD Text
OSG中hud的使用方法与示例代码。需要借助OSG三维库。
HUD标定模式增加两个状态.doc
2D控件与3D模型的完善结合,NGUI HUD需要NGUI的支持,项目中需要先导入NGUI否则HUD可不能使用的
Unity3d HUD waypoint 1.0.3 class
hud