posts - 99,  comments - 8,  trackbacks - 0
#include <stdio.h>
#
include <stdlib.h>
#
include <string.h>
#
include <math.h>
int main ()
{
    int a[
1000];
    int n;
    
while ( scanf ("%d"&n) && n )
    {
          a[0] 
= 0;
          
for ( int i = 1; i <= n; i ++ )
          {
              scanf (
"%d"&a[i]);
          }
          
          int sum 
= 0;
          
for ( int i = 1; i <= n; i ++ )
          {
              
if ( a[i] > a[i - 1] )
              {
                   sum 
+= (a[i] - a[i - 1]) * 6 + 5;
              }
              
else if ( a[i] < a[i - 1])
              {
                   sum 
+= (a[i - 1- a[i]) * 4 + 5;
              }
              
else
              {
                  sum 
+= 5;
              }
          }
          
          printf (
"%d\n", sum);
    }
   system (
"pause");
   
return 0;
}
posted on 2010-09-03 18:37 雪黛依梦 阅读(205) 评论(0)  编辑 收藏 引用 所属分类: 简单题

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(4)

随笔分类

随笔档案

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜