#include <iostream>
#include <vector>
int main() {
long iloscTestow{};
std::string line;
std::cin >> iloscTestow;
std::cin >> line;
long grupa = iloscTestow / 10;
long result{};
long groupResult{};
long groupCount{};
for (int i = 0; i < iloscTestow; i++) {
if (line[i] == 'T') {
groupResult++;
}
groupCount++;
if (groupCount == grupa) {
if (groupResult == grupa) {
result++;
}
groupCount = 0;
groupResult = 0;
}
}
std::cout << result << std::endl;
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 | #include <iostream> #include <vector> int main() { long iloscTestow{}; std::string line; std::cin >> iloscTestow; std::cin >> line; long grupa = iloscTestow / 10; long result{}; long groupResult{}; long groupCount{}; for (int i = 0; i < iloscTestow; i++) { if (line[i] == 'T') { groupResult++; } groupCount++; if (groupCount == grupa) { if (groupResult == grupa) { result++; } groupCount = 0; groupResult = 0; } } std::cout << result << std::endl; return 0; } |
English