#include <string> #include <iostream> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; string S; cin >> n >> S; int len = n/10, res = 0; for(int i=0;i<n;i+=len) res += all_of(S.begin() + i, S.begin() + i + len, [](auto x){return x=='T';}); cout << res << '\n'; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <string> #include <iostream> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; string S; cin >> n >> S; int len = n/10, res = 0; for(int i=0;i<n;i+=len) res += all_of(S.begin() + i, S.begin() + i + len, [](auto x){return x=='T';}); cout << res << '\n'; return 0; } |