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