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();
} }
HDOJ-ACM1008(JAVA)的更多相关文章
- hdoj 1753 (Java)
刚刚开始用Java,代码难免不够简洁. import java.math.BigDecimal; import java.util.Scanner; public class Main { publi ...
- Spark案例分析
一.需求:计算网页访问量前三名 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...
- HDOJ/HDU 2203 亲和串(简单的判断~Java的indexOf()方法秒)
Problem Description 人随着岁数的增长是越大越聪明还是越大越笨,这是一个值得全世界科学家思考的问题,同样的问题Eddy也一直在思考,因为他在很小的时候就知道亲和串如何判断了,但是发现 ...
- HDOJ(HDU) 2192 MagicBuilding(用Java的Map做了下)
Problem Description As the increase of population, the living space for people is becoming smaller a ...
- HDOJ(HDU) 2133 What day is it(认识下Java的Calendar类---日期类)
Problem Description Today is Saturday, 17th Nov,2007. Now, if i tell you a date, can you tell me wha ...
- hdoj 1753 大明A+B 高精度/java
大明A+B Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdoj 1002 A + B Problem II 高精度 java
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- HDOJ 1326. Box of Bricks 纯水题
Box of Bricks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
随机推荐
- Codeforces Round #345 (Div. 1) A. Watchmen 模拟加点
Watchmen 题意:有n (1 ≤ n ≤ 200 000) 个点,问有多少个点的开平方距离与横纵坐标的绝对值之差的和相等: 即 = |xi - xj| + |yi - yj|.(|xi|, |y ...
- 常用 xwt 工具
1,显示提示信息 <FString chnName="执行单位" prompt="可以进行模糊匹配" required="false" ...
- appfabric 简单应用
http://msdn.microsoft.com/en-us/library/ee790941(v=azure.10).aspx Preparing the Visual Studio Projec ...
- python 程序列表
用 python 通过读取注册表来获取机器安装的程序列表,包括,软件名称,版本号,安装日期等 # -*- coding: UTF8 -*-import _winregimport osimport ...
- 实现strlen,strcpy,strcat,strcmp同功能的函数stringLength,stringCopy,stringCatch,stringCompare
#import <Foundation/Foundation.h> /* 求字符串长度 */ int stringLength(char arr[]); /* 复制字符串 将arr1 复制 ...
- js library
jquery.js prototype.js requirejs.js backbone.js modernizr.js knockout.js http://share.renren.com/sha ...
- gcc和g++的区别
参考What is the difference between g++ and gcc? 1.The actual compiler is "cc1" for C and &qu ...
- CSS使块半透明方法,兼容IE6
前言 今天LOL玩机器人玩得真心不爽,实在崩溃,还是逛博客园比较爽些,记录自己的成长!说句实话我在编程方面确实是个菜鸟,菜到一种超神的地步,没一样自己特擅长的,悲催...... 废话少说,进入正题,H ...
- HDU1395+快速幂
#include<stdio.h> int fast_pow( int a,int b,int mod ){ ; ){ == ){ res = res*a%mod; } a = a*a%m ...
- WebBrowser控件的高级定制+mshtml
--> blog:WebBrowser控件的高级定制---以下为三篇重要的参考文献, 第一篇可以禁用了js弹窗和声音 第二篇的引用文献禁用了IE弹窗,但是原文的说明很好 第3篇 ...