#include <iostream> #include <string> using namespace std; int main() { int n; string str; int size; int res {}; cin >> n >> str; size = n/10; string pattern(size, 'T'); for (int i=0; i<n; i+=size) { if (pattern.compare(str.substr(i, size)) == 0) { res++; } } cout << res << endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <iostream> #include <string> using namespace std; int main() { int n; string str; int size; int res {}; cin >> n >> str; size = n/10; string pattern(size, 'T'); for (int i=0; i<n; i+=size) { if (pattern.compare(str.substr(i, size)) == 0) { res++; } } cout << res << endl; return 0; } |