zoukankan      html  css  js  c++  java
  • hdu1008Elevator

    http://acm.hdu.edu.cn/showproblem.php?pid=1008

    #include <iostream>
    using namespace std;
    int
    main(int argc, char *argv[])
    {

        int
    n;
        int
    a;
        while
    (cin>>n)
        {
       
    if
    (n>0)
            {

            int
    i=0;
            int
    s=0;
            while
    (n--)
            {

                cin>>a;
                if
    (i<a)
                {

                    s+=6*(a-i);
                    s+=5;
                    i=a;
                }

                else

                {

                    s+=4*(i-a);
                    s+=5;
                    i=a;
                }
               
            }

                cout<<s<<endl;
        }

        else break
    ;
        }

            return
    0;
    }

  • 相关阅读:
    其他
    Win10
    Win10
    面向对象与设计模式
    Git
    Java
    Git
    Git
    Git
    一、I/O操作(File文件对象)
  • 原文地址:https://www.cnblogs.com/beibeibao/p/2995106.html
Copyright © 2011-2022 走看看