hdoj1008简单题

来源:互联网 发布:农村淘宝报名入口 编辑:程序博客网 时间:2024/05/29 10:58
#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;    }}