tmp记录上一次跳的值1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include<iostream>
using namespace std;
int main(){
int a;
int plus=0,tmp;
int sum=0;
while(1){
scanf("%d",&a);
if(a==0) break;
if(a==1){
sum+=1;
}
else
{
if(tmp==2) plus+=2;
else plus=2;
sum+=plus;
}
tmp=a;
}
cout<<sum<<endl;
}