#include<iostream> using namespace std; int main(){ int n; cin>>n; string s; cin>>s; int g=n/10; int c=0; int res=0; for (int i = 1; i <= n; i++) { if(s[i-1]=='T'){ c++; } if(i%g==0){ if(c==g){ res++; } c=0; } } 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 | #include<iostream> using namespace std; int main(){ int n; cin>>n; string s; cin>>s; int g=n/10; int c=0; int res=0; for (int i = 1; i <= n; i++) { if(s[i-1]=='T'){ c++; } if(i%g==0){ if(c==g){ res++; } c=0; } } cout<<res; return 0; } |