HDU-1008 电梯啊电梯

这个题目一开始看错了题目,理解错了意思。。。唉,总是犯这种毛病啊悲催,记得去buaa也是犯了这毛病害的第一题就没AC,哭……

好了,上源码!

 1 #include <stdio.h>
 2 
 3 int main(){
 4     int up = 6, down = 4, stop = 5;
 5     int n, i;
 6     while((scanf("%d",&n) != EOF)&& n){
 7         int floor, fore = 0, time = 0;
 8         for(i = 0; i < n; i++){
 9             scanf("%d",&floor);
10             if(floor > fore){
11                 time += up * (floor - fore) + stop;
12             }
13             else{
14                 time += down * (fore - floor) + stop;
15             }
16             fore = floor;
17         }
18         printf("%d
",time);
19     }
20     return 0;
21 }

嗯。

Everything will be ok in the end. If it is not ok then it is not the end.
原文地址:https://www.cnblogs.com/shirleytian/p/3200759.html