#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int k = n/10, wynik = 0; string a; cin >> a; for (int i = 0; i < a.size(); i += k) { int w = 0; for (int j = i; j <= i+k-1; j++) { if(a[j] == 'T') w++; } if(w == k) wynik++; } cout << wynik << "\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int k = n/10, wynik = 0; string a; cin >> a; for (int i = 0; i < a.size(); i += k) { int w = 0; for (int j = i; j <= i+k-1; j++) { if(a[j] == 'T') w++; } if(w == k) wynik++; } cout << wynik << "\n"; } |