Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int INF = 1e9;
- const int N = 1e5;
- char str[N+10];
- int main(){
- scanf("%s", str);
- int L = strlen(str);
- int mn = INF;
- for(int l=1;l<=L/2;l++){
- if(L % l != 0) continue;
- int cnt = 0;
- for(int i=0;i<l;i++){
- int K[27];
- for(int j=0;j<=26;j++) K[j] = 0;
- int mx = 0, c = -1;
- for(int j=i;j<L;j+=l) {
- K[ str[j]-'a'+1 ] ++;
- if(K[ str[j]-'a'+1 ] > mx){
- mx = K[ str[j]-'a'+1 ];
- c = str[j]-'a'+1;
- }
- }
- for(int j=0;j<=26;j++){
- if(j != c){
- cnt += K[j];
- }
- }
- }
- mn = min(mn, cnt);
- }
- printf("%d", mn);
- return 0;
- }
- /**
- abbbab
- ababb
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement