YEZAELP

CUBE-156: Codecubecodecube

Jul 11th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.  
  7.     string str,cmp;
  8.     cmp="codecube";
  9.     cin>>str;
  10.     int l=str.size(),c=cmp.size(),cnt=0,j=0;
  11.  
  12.     for(int i=0;i<l;i++){
  13.         while(cmp[j]!=str[i]){
  14.             j++;
  15.             cnt++;
  16.             if(c==j) j=0;
  17.         }
  18.         j++;
  19.         if(c==j) j=0;
  20.     }
  21.     if(j!=0) cnt+=c-(j);
  22.     printf("%d",cnt);
  23.  
  24.     return 0;
  25. }
Add Comment
Please, Sign In to add comment