#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int res = 0; for (int i = 0; i < n; i += n / 10) { res += s.substr(i, n / 10) == string(n / 10, 'T'); } cout << res << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <iostream> #include <algorithm> #include <string> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int res = 0; for (int i = 0; i < n; i += n / 10) { res += s.substr(i, n / 10) == string(n / 10, 'T'); } cout << res << endl; } |