#include <stdio.h>
#include <algorithm>
bool isGroupOk(const char* data, const int group, const int groupSize) {
return std::all_of(&data[group * groupSize], &data[(group + 1) * groupSize],
[](const char& c) { return c == 'T'; });
}
int main() {
int n;
char data[101];
scanf("%d\n", &n);
scanf("%s\n", data);
const int groups = 10;
const int groupSize = n / groups;
int result = 0;
for (int group = 0; group < groups; ++group) {
if (isGroupOk(data, group, groupSize)) {
result++;
}
}
printf("%d\n", result);
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 | #include <stdio.h> #include <algorithm> bool isGroupOk(const char* data, const int group, const int groupSize) { return std::all_of(&data[group * groupSize], &data[(group + 1) * groupSize], [](const char& c) { return c == 'T'; }); } int main() { int n; char data[101]; scanf("%d\n", &n); scanf("%s\n", data); const int groups = 10; const int groupSize = n / groups; int result = 0; for (int group = 0; group < groups; ++group) { if (isGroupOk(data, group, groupSize)) { result++; } } printf("%d\n", result); return 0; } |
English