标签:
非常简单的模拟
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 }
标签:
原文地址:http://www.cnblogs.com/Artprog/p/4852771.html