#include <iostream> using namespace std; int suma[150], n, res; char c; int main() { cin >> n; for(int i = 1; i<n+1; i++){ cin >> c; if(c == 'T') { suma[i] = suma[i-1] + 1; } else { suma[i] = suma[i-1]; } } int k = n/10; for(int i = 1; i<11; i++) { if(suma[i*k] - suma[(i-1)*k] == k) { res ++; } } 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 25 26 27 28 29 30 31 32 | #include <iostream> using namespace std; int suma[150], n, res; char c; int main() { cin >> n; for(int i = 1; i<n+1; i++){ cin >> c; if(c == 'T') { suma[i] = suma[i-1] + 1; } else { suma[i] = suma[i-1]; } } int k = n/10; for(int i = 1; i<11; i++) { if(suma[i*k] - suma[(i-1)*k] == k) { res ++; } } cout << res; return 0; } |