#include<iostream> using namespace std; int main() { int n; cin >> n; int k = n/10; int t = 0; //ile dobrych w segmencie int l = 0; //ile dorbych segmentow for(int i = 1; i <= n; i++) { char a; cin >> a; if(a == 'T') t++; if(i%k == 0) { if(t == k) l++; t = 0; } } cout << l << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include<iostream> using namespace std; int main() { int n; cin >> n; int k = n/10; int t = 0; //ile dobrych w segmencie int l = 0; //ile dorbych segmentow for(int i = 1; i <= n; i++) { char a; cin >> a; if(a == 'T') t++; if(i%k == 0) { if(t == k) l++; t = 0; } } cout << l << endl; } |