#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int fin = 0;
int ct=0, ctt=0;
for(int i = 0;i < n ;i++){
char temp;
cin >> temp;
if(temp=='T'){
ctt++;
}
ct++;
if(ct==n/10){
if(ct==ctt) fin++;
ct=0; ctt=0;
}
}
cout << fin;
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 | #include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int fin = 0; int ct=0, ctt=0; for(int i = 0;i < n ;i++){ char temp; cin >> temp; if(temp=='T'){ ctt++; } ct++; if(ct==n/10){ if(ct==ctt) fin++; ct=0; ctt=0; } } cout << fin; return 0; } |
English