#include <iostream> #include <string> int main() { int n; std::cin >> n; std::string s; std::cin >> s; int group_size = n / 10, res = 0; for(int i = 0; i < n; i += group_size) { int passing_in_group = 0; for(int j = i, end = i + group_size; j < end; ++j) passing_in_group += s[j] == 'T'; if(passing_in_group == group_size) ++res; } std::cout << res << '\n'; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <iostream> #include <string> int main() { int n; std::cin >> n; std::string s; std::cin >> s; int group_size = n / 10, res = 0; for(int i = 0; i < n; i += group_size) { int passing_in_group = 0; for(int j = i, end = i + group_size; j < end; ++j) passing_in_group += s[j] == 'T'; if(passing_in_group == group_size) ++res; } std::cout << res << '\n'; } |