#include <iostream> using namespace std; int tab[102]; int main() { int n; cin>>n; int w=0; for(int i=1;i<=n;i++){ char c; cin>>c; if(c=='T'){tab[i]=tab[i-1]+1;}else{tab[i]=0;} } for(int j=n/10;j<=n;j+=(n/10)){ if(tab[j]>=(n/10)){w++;} } cout<<w; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> using namespace std; int tab[102]; int main() { int n; cin>>n; int w=0; for(int i=1;i<=n;i++){ char c; cin>>c; if(c=='T'){tab[i]=tab[i-1]+1;}else{tab[i]=0;} } for(int j=n/10;j<=n;j+=(n/10)){ if(tab[j]>=(n/10)){w++;} } cout<<w; return 0; } |