#include <iostream> int main() { std::ios::sync_with_stdio(false); int n; std::cin >> n; int group_size = n / 10; int result = 0; char c; bool correct; for (int i = 0; i < n; ++i) { std::cin >> c; if (i % group_size == 0) { correct = true; } correct = correct && (c == 'T'); if ((i % group_size == group_size - 1) && correct) { result += 1; } } std::cout << result << std::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 | #include <iostream> int main() { std::ios::sync_with_stdio(false); int n; std::cin >> n; int group_size = n / 10; int result = 0; char c; bool correct; for (int i = 0; i < n; ++i) { std::cin >> c; if (i % group_size == 0) { correct = true; } correct = correct && (c == 'T'); if ((i % group_size == group_size - 1) && correct) { result += 1; } } std::cout << result << std::endl; } |