parent
c225c03e12
commit
2a53a64b8f
@ -0,0 +1,20 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int cnt = 1;
|
||||
void dfs(string s) {
|
||||
int p;
|
||||
for (p = s.size() - 1; p; p--)
|
||||
if (s[0] != s[p]) break;
|
||||
string t = s.substr(1, p);
|
||||
if (t.size()) cnt++, dfs(t);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
string s;
|
||||
cin >> n >> s;
|
||||
dfs(s);
|
||||
cout << cnt << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue