#include<iostream> #include<string> using namespace std; int main() { int n; string s; cin >> n >> s; int k = n / 10, cnt = 0, res = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'T') { cnt++; } if (i % k == k - 1) { if (cnt == k) { res++; } cnt = 0; } } cout << res; 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 | #include<iostream> #include<string> using namespace std; int main() { int n; string s; cin >> n >> s; int k = n / 10, cnt = 0, res = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'T') { cnt++; } if (i % k == k - 1) { if (cnt == k) { res++; } cnt = 0; } } cout << res; return 0; } |