#include <iostream> #include <string> using namespace std; int main() { int n, block; string input; ios_base::sync_with_stdio(false); cin >> n >> input; block = n / 10; int cnt = 0; for (int i = 0; i < n; i += block) { int result = 1; for (int j = 0; j < block; j++) result &= input[i + j] == 'T'; cnt += result; } cout << cnt; 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 25 | #include <iostream> #include <string> using namespace std; int main() { int n, block; string input; ios_base::sync_with_stdio(false); cin >> n >> input; block = n / 10; int cnt = 0; for (int i = 0; i < n; i += block) { int result = 1; for (int j = 0; j < block; j++) result &= input[i + j] == 'T'; cnt += result; } cout << cnt; return 0; } |