[数学题]HDU1008 Elevator


http://acm.hdu.edu.cn/showproblem.php?pid=1008
按步就班的来就行了~模拟题
[c]
#include <stdio.h>
#include <stdlib.h>

int main()
{
//freopen("test.txt","r",stdin);
int N,i,floor[105],sum;
while(scanf("%d",&N) && N!=0)
{
sum=5*N;
floor[0]=0;
for(i=1;i<=N;i++)
{
scanf("%d",&floor[i]);
if(floor[i]>floor[i-1])
sum+=6*(floor[i]-floor[i-1]);
else
sum+=4*(floor[i-1]-floor[i]);
}
printf("%dn",sum);
}
return 0;
}
[/c]

发表评论