Topic link: http://codeforces.com/problemset/problem/977/B
The meaning of the question: string, find the repeated substring with a fixed length of 2 with the most occurrences.
Solution: I did it violently. Violence works wonders.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<iostream> 2 using namespace std; 3 #define maxn 105 4 5 char a[maxn]; 6 int main(){ 7 int n; 8 cin>>n; 9 for(int i = 0; i < n ;i++){ 10 cin>>a[i]; 11 } 12 int max = 0; 13 int maxi; 14 int cnt = 0; 15 for(int i = 0; i < n ;i++){ 16 cnt = 0; 17 for(int j = i+1 ; j < n ;j++){ 18 19 if(a[i] == a[j] && a[i+1] == a[j+1]){ 20 cnt++; 21 } 22 } 23 if(cnt > max){ 24 max = cnt; 25 maxi = i; 26 } 27 } 28 29 cout<<a[maxi]<<a[maxi+1]<<endl; 30 31 32 33 return 0; 34 }