#include <bits/stdc++.h>
using namespace std;
bool cnt(string &s, int a, int b)
{
int i = a;
while (s[i] == 'T' and i < a + b)
{
i++;
}
if (i == a + b)
{
return(true);
}
else
{
return(false);
}
}
int main()
{
int n, o = 0;
string s;
cin >> n >> s;
for (int i = 0; i < n; i += n / 10)
{
if (cnt(s, i, n / 10) == true)
{
o++;
}
}
cout << o << "\n";
}
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 | #include <bits/stdc++.h> using namespace std; bool cnt(string &s, int a, int b) { int i = a; while (s[i] == 'T' and i < a + b) { i++; } if (i == a + b) { return(true); } else { return(false); } } int main() { int n, o = 0; string s; cin >> n >> s; for (int i = 0; i < n; i += n / 10) { if (cnt(s, i, n / 10) == true) { o++; } } cout << o << "\n"; } |
English