csp 201803-1 jump jump

// Score 100 
#include <the iostream> the using namespace STD; int main () { int A; // a first number of separate treatment CIN >> A; int SUM; // all scores and IF (A == . 1 ) = SUM . 1 ; IF (a == 2 ) SUM = 2 ; IF (a == 0 ) SUM = 0 ; int i = SUM; // case where the recording step, the following set values of i is to be noted the while (SUM! = 0 ) {// zero, then the first step, the ends int K; CIN>>k; if(k==0) break;//game over if(k==1) {i=0;sum+=1;}//不是中心点,加1 if(k==2){ if(i>=2) {i+=2;sum+=i;}//是中心点且连跳,加上一次加二 else {i=2;sum+=2;} //中心点但不连跳,仅加二 } } cout<<sum<<endl; return 0; }

 

Guess you like

Origin www.cnblogs.com/i-love/p/11306474.html