201803-1 跳一跳
简单模拟~。
int a[35];
int score[35];
int n;
int main()
{
int sum=0;
while(cin>>a[n],a[n])
{
if(a[n] == 1) score[n]=1;
else if(n==0 || a[n-1] == 1) score[n]=2;
else score[n]=score[n-1]+2;
sum+=score[n];
n++;
}
cout<<sum<<endl;
//system("pause");
return 0;
}