HDU1008
来源:互联网 发布:mac book pro官网 编辑:程序博客网 时间:2024/06/05 06:03
//import java.text.DecimalFormat;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
if(n==0)System.exit(0);
int pre=0;
int total=0;
for(int i=1;i<=n;i++)
{int num=sc.nextInt();
if(num>pre){total+=6*(num-pre)+5;pre=num;}
else if(num<pre){total+=4*(pre-num)+5;pre=num;}
else total+=5;
}
System.out.println(total);
}
}
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int n=sc.nextInt();if(n==0)System.exit(0);
int pre=0;
int total=0;
for(int i=1;i<=n;i++)
{int num=sc.nextInt();
if(num>pre){total+=6*(num-pre)+5;pre=num;}
else if(num<pre){total+=4*(pre-num)+5;pre=num;}
else total+=5;
}
System.out.println(total);
}
}
}
0 0
- hdu1008
- hdu1008
- hdu1008
- hdu1008
- HDU1008
- HDU1008
- HDU1008
- hdu1008
- hdu1008
- HDU1008
- hdu1008
- HDU1008
- HDU1008
- HDU1008
- HDU1008
- HDU1008
- hdu1008
- HDU1008 Elevator
- 2017 华东师范大学网赛 F.丽娃河的狼人传说( 贪心)
- 子元素上的margin作用到了父元素上
- [设计模式]观察者模式(Observer)
- linux下的socket基础编程
- Maven搭建Spring+Struts2+Mybatis项目(二) web.xml设置
- HDU1008
- Android界面设计之个人资料界面
- Redis简介
- 纪念我的第一篇CSDN博客-mac系统下cplex和yamip的配置以及在matlab中的调用
- leetcode 5. Longest Palindromic Substring Add to List
- oracle代码静态性能扫描
- 深入理解Java常用类----String(二)
- LeedCode 之 Merge Sorted Array
- Hadoop集群搭建(hadoop+zookeeper+hbase)Ubuntu14.04