您的位置:首页 > 其它

hdoj1008简单题

2013-02-22 00:25 190 查看
#include<iostream>
using namespace std;

int main(){
int m;
int n;
int pre;
int total;
for(cin>>m; m != 0; cin>>m){
cin>>n;
pre = n;
total = n * 6;
total = total + 5;
for(int i = 1; i < m; i++){
cin>>n;
if(n > pre){
total = total + 6 * (n - pre);
pre = n;
}else if(n < pre){
total = total + 4 * (pre - n);
pre = n;
}
total = total + 5;
}
cout<<total<<endl;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: