#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); typedef long long ll;typedef long double ld;typedef pair<int,int> pii; #define F first #define S second #define PB push_back #define MP make_pair #define all(x) (x).begin(), (x).end() const ll mod = 1e9+7, N = 2e6+7, M = 2e6+7, INF = INT_MAX/10; ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;} void solve(){ int n; cin >> n; string s; cin >> s; int res = 0; for(int i=0; i<n; i+=n/10){ int cnt = 0; for(int j=i; j<i+n/10; j++){ if(s[j] == 'T') cnt++; } if(cnt == n/10) res++; } cout << res << '\n'; } signed main(){ fast; int t = 1; //cin >> t; while(t--){ solve(); } 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); typedef long long ll;typedef long double ld;typedef pair<int,int> pii; #define F first #define S second #define PB push_back #define MP make_pair #define all(x) (x).begin(), (x).end() const ll mod = 1e9+7, N = 2e6+7, M = 2e6+7, INF = INT_MAX/10; ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;} void solve(){ int n; cin >> n; string s; cin >> s; int res = 0; for(int i=0; i<n; i+=n/10){ int cnt = 0; for(int j=i; j<i+n/10; j++){ if(s[j] == 'T') cnt++; } if(cnt == n/10) res++; } cout << res << '\n'; } signed main(){ fast; int t = 1; //cin >> t; while(t--){ solve(); } return 0; } |