码迷,mamicode.com
首页 > 其他好文 > 详细

HDUOJ 1008 Elevator

时间:2015-10-02 22:28:47      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:

非常简单的模拟

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <stdlib.h>
 4 const int up = 6;
 5 const int down = 4;
 6 const int stop = 5;
 7 int main()
 8 {
 9     int n, total_time, timecost;
10     int from, to;
11     while(1 == scanf("%d", &n) && n)
12     {
13         from = total_time = 0;
14         for(int i = 0; i < n; ++i)
15         {
16             scanf("%d", &to);
17             timecost = (to > from) ? up : down;
18             total_time += timecost * abs(to - from) + stop;
19             from = to;
20         }
21         printf("%d\n", total_time);
22     }
23     return 0;
24 }

 

HDUOJ 1008 Elevator

标签:

原文地址:http://www.cnblogs.com/Artprog/p/4852771.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!