#include <iostream> using namespace std; int main() { int n; cin >> n; string line; cin >> line; int group_size = n / 10; int groups_passed = 0; int i = 0; while (i < n) { int group_passed = 1; for (int j = 0; j < group_size; ++j) { if (line[i] != 'T') { group_passed = 0; } i++; } groups_passed += group_passed; } cout << groups_passed << 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 | #include <iostream> using namespace std; int main() { int n; cin >> n; string line; cin >> line; int group_size = n / 10; int groups_passed = 0; int i = 0; while (i < n) { int group_passed = 1; for (int j = 0; j < group_size; ++j) { if (line[i] != 'T') { group_passed = 0; } i++; } groups_passed += group_passed; } cout << groups_passed << endl; return 0; } |