Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- string str,cmp;
- cmp="codecube";
- cin>>str;
- int l=str.size(),c=cmp.size(),cnt=0,j=0;
- for(int i=0;i<l;i++){
- while(cmp[j]!=str[i]){
- j++;
- cnt++;
- if(c==j) j=0;
- }
- j++;
- if(c==j) j=0;
- }
- if(j!=0) cnt+=c-(j);
- printf("%d",cnt);
- return 0;
- }
Add Comment
Please, Sign In to add comment