CSP2018-03
CSP201803-1 跳一跳
1 // 2 // main.cpp 3 // CSP201803-1 跳一跳 4 // 5 // Created by sylvia on 2021/11/6. 6 // Copyright © 2021 apple. All rights reserved. 7 // 8 9 #include <iostream> 10 using namespace std; 11 int main(){ 12 int n,s=1,ans=0; 13 while (cin>>n && n!=0){ 14 switch(n){ 15 case 1:{ 16 ans+=1; 17 s=1; 18 break; 19 } 20 case 2:{ 21 ans+=2*s; 22 s++; 23 break; 24 } 25 } 26 } 27 cout<<ans<<endl; 28 29 return 0; 30 }