HDU1008 Elevator

简介:
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1008

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{

int n,curLev,desLev,sumTime,tmp;

while(cin>>n&&n!=0)

{

curLev = 0;//初始层为0

sumTime = 0;

for(int i=0;i<n;++i)

{

cin>>desLev;//目标层

tmp = desLev-curLev;

if(tmp>0)

{//上楼

sumTime += tmp*6+5;

}

else

{//下楼

tmp = -tmp;

sumTime += tmp*4+5;

}

curLev = desLev;//修改当前所在层

}

cout<<sumTime<<endl;

}

return 0;

}


本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2007/12/23/1011835.html,如需转载请自行联系原作者

目录
相关文章
|
6月前
|
Java
HDU-1004—Let the Balloon Rise
HDU-1004—Let the Balloon Rise
30 0
|
6月前
Strange fuction(HDU--2899)
Strange fuction(HDU--2899)
UVA699 下落的树叶 The Falling Leaves
UVA699 下落的树叶 The Falling Leaves
UVA699 下落的树叶 The Falling Leaves
HDU-1097,A hard puzzle(快速幂)
HDU-1097,A hard puzzle(快速幂)
|
测试技术
HDU-1026,Ignatius and the Princess I(BFS+打印路径)
HDU-1026,Ignatius and the Princess I(BFS+打印路径)
|
算法 Go
HDU-1548,A strange lift(Dijkstra)
HDU-1548,A strange lift(Dijkstra)