AcWing每日一题--跳一跳

https://www.acwing.com/problem/content/3260/

水题。

每次记录上一次连续多少次跳到了中心即可。

 1 #include<iostream>
 2 using namespace std;
 3 int main(void){
 4     int res=0,point=1;
 5     int t;
 6     while(cin>>t&&t){
 7         if(t==1){
 8             res+=1;
 9             point=1;
10         }else{
11             res+=point*2;
12             point++;
13         }
14     }
15     cout<<res;
16     return 0;
17 }
原文地址:https://www.cnblogs.com/greenofyu/p/14555887.html