#include <iostream> using namespace std; long long n,k,p; string a; int main() { cin>>n; cin>>a; for(int i=0; i<n; i++) {if(a[i]=='T') k++; if(a[i]!='T') k=0; if(k==n/10) {p++; k=0;} } cout<<p; return 0; }
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; long long n,k,p; string a; int main() { cin>>n; cin>>a; for(int i=0; i<n; i++) {if(a[i]=='T') k++; if(a[i]!='T') k=0; if(k==n/10) {p++; k=0;} } cout<<p; return 0; } |