#include <iostream> #include <string> int64_t n, k = 0, r = 0; bool ok; char s[101]; int main() { std::ios::sync_with_stdio(false); std::cin >> n; std::cin >> s; k = n / 10; ok = true; for (decltype(n) i = 0; i < n; i++) { if (s[i] != 'T') { ok = false; } if (i % k == k - 1) { if (ok) { ++r; } ok = true; } } std::cout << r << "\n"; }
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 | #include <iostream> #include <string> int64_t n, k = 0, r = 0; bool ok; char s[101]; int main() { std::ios::sync_with_stdio(false); std::cin >> n; std::cin >> s; k = n / 10; ok = true; for (decltype(n) i = 0; i < n; i++) { if (s[i] != 'T') { ok = false; } if (i % k == k - 1) { if (ok) { ++r; } ok = true; } } std::cout << r << "\n"; } |