Time Limit:1000MS Memory Limit:32768KB 64bit
IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
while ((n = sc.nextInt()) != 0) {
int start = 0;
int t = 0;
while (n-- != 0) {
int j = sc.nextInt();
if (j > start) {
t += 6 * (j - start);
} else {
t += 4 * (start - j);
}
start = j;
t += 5;
}
System.out.println("" + t);
}
}
}
原文:http://www.cnblogs.com/A--Q/p/5665206.html