#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; bitset<N> odw; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; string s; cin>>n>>s; for(int i=0;i<n;i++){ if(s[i]=='T') odw[i+1]=true; } int ile=n/10, ans=0; for(int i=1;i<=n;i+=ile){ bool ok = false; for(int j=i;j<i+ile;j++){ if(!odw[j]) ok=true; } if(!ok) ans++; } cout<<ans; 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 | #include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; bitset<N> odw; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; string s; cin>>n>>s; for(int i=0;i<n;i++){ if(s[i]=='T') odw[i+1]=true; } int ile=n/10, ans=0; for(int i=1;i<=n;i+=ile){ bool ok = false; for(int j=i;j<i+ile;j++){ if(!odw[j]) ok=true; } if(!ok) ans++; } cout<<ans; return 0; } |