HDOJ-ACM1008(JAVA)
这道题很简单,主要是要搞清楚题目的意思
以下是JAVA语言实现:
import java.util.*; import java.io.*; public class Main{ public static void main(String[] arg){ Scanner scan = new Scanner(new BufferedInputStream(System.in)); int n; while((n=scan.nextInt())!=0){ int time = 0; int before = 0; while(n--!=0){ int a = scan.nextInt(); if(a<before){ time = time + (before-a)*4 + 5; }else{ time = time + (a - before)*6 + 5; } before = a; } System.out.println(time); } scan.close(); } }
让蔷薇开出一种结果~