You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
619 B

1 year ago
#include <bits/stdc++.h>
using namespace std;
/*
5
12321
1
2
*/
int cnt = 1;
// 循环写法
void cut(string s) {
while (true) {
int p;
for (p = s.size() - 1; p; p--)
if (s[0] != s[p]) break;
string t;
for (int i = 1; i <= p; i++) t += s[i];
if (t.size())
cnt++, s = t;
else
break;
}
}
int main() {
int n;
string s;
cin >> n >> s;
cut(s);
cout << cnt << endl;
return 0;
}