#include <bits/stdc++.h> using namespace std; char buff[1000]; int main() { int n; scanf("%d%s", &n, buff + 1); int m = n / 10; int cnt = 0, w = 0; for(int i = 1; i <= n; i++) { if(buff[i] == 'T') cnt++; if(!(i % m)) { if(cnt == m) w++; cnt = 0; } } cout << w << endl; 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 | #include <bits/stdc++.h> using namespace std; char buff[1000]; int main() { int n; scanf("%d%s", &n, buff + 1); int m = n / 10; int cnt = 0, w = 0; for(int i = 1; i <= n; i++) { if(buff[i] == 'T') cnt++; if(!(i % m)) { if(cnt == m) w++; cnt = 0; } } cout << w << endl; return 0; } |