pat1008 Elevator

#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int main()
{
  int n,i,pre,ans,x;
  while(scanf("%d",&n)!=EOF)
  {
    ans = pre = 0;
    for(i = 0;ipre)ans+=(x-pre)*6;
      else ans+=(pre-x)*4;
      pre = x;
    }
    printf("%d\n",ans);
  }
  return 0;
}

你可能感兴趣的:(PAT)