#include <iostream> #define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) using namespace std; const int GROUP_COUNT = 10; int n, groupSize, result; string s; bool didGroupPass(int firstIndex, int lastIndex) { for (int it = firstIndex; it <= lastIndex; it++) { if (s[it] != 'T') { return false; } } return true; } int main() { boost; cin >> n; cin >> s; groupSize = n / GROUP_COUNT; for (int i = 0; i < GROUP_COUNT; i++) { result += didGroupPass(i * groupSize, (i + 1) * groupSize - 1); } cout << result << endl; }
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 26 27 28 29 30 31 32 33 | #include <iostream> #define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) using namespace std; const int GROUP_COUNT = 10; int n, groupSize, result; string s; bool didGroupPass(int firstIndex, int lastIndex) { for (int it = firstIndex; it <= lastIndex; it++) { if (s[it] != 'T') { return false; } } return true; } int main() { boost; cin >> n; cin >> s; groupSize = n / GROUP_COUNT; for (int i = 0; i < GROUP_COUNT; i++) { result += didGroupPass(i * groupSize, (i + 1) * groupSize - 1); } cout << result << endl; } |