bp神经网络模型,2013年公务员考试真题,鳄梨是什么
time limit: 2000/1000 ms (java/others) memory limit: 65536/32768 k (java/others)total submission(s): 30095 accepted submission(s): 16272
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
水题(话说有这么zz的电梯吗23333)
代码样例
#include <stdio.h> int main() { int t; while (scanf("%d",&t) != eof,t != 0) { int time=0,temp=0; for(int i=0; i < t; i++) { int n; scanf("%d",&n); if(temp < n) { time=time+(n-temp)*6; temp=n; } if(temp > n) { time=time+(temp-n)*4; temp=n; } if(temp == n) time=time+5; } printf("%d\n",time); } return 0; }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论