#include <bits/stdc++.h> using namespace std; int cnt[105]; int32_t main() { int n; string s; cin >> n >> s; int per_test = n / 10; for (int i = 0; i < s.size(); i++) { cnt[i / per_test] += (s[i] == 'T'); } int res = 0; for (int i = 0; i < n / per_test; i++) { res += (cnt[i] == per_test); } cout << res << "\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <bits/stdc++.h> using namespace std; int cnt[105]; int32_t main() { int n; string s; cin >> n >> s; int per_test = n / 10; for (int i = 0; i < s.size(); i++) { cnt[i / per_test] += (s[i] == 'T'); } int res = 0; for (int i = 0; i < n / per_test; i++) { res += (cnt[i] == per_test); } cout << res << "\n"; } |