#include <stdio.h> int main() { int n; char word[101]; scanf("%d", &n); scanf("%s", word); int chunk = n / 10; int c = 0; bool passed = true; int total = 0; for (int i = 0; i < n; ++i) { passed = passed && (word[i] == 'T'); ++c; if (c == chunk) { if (passed) { ++total; } c = 0; passed = true; } } printf("%d\n", total); 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 29 30 31 32 | #include <stdio.h> int main() { int n; char word[101]; scanf("%d", &n); scanf("%s", word); int chunk = n / 10; int c = 0; bool passed = true; int total = 0; for (int i = 0; i < n; ++i) { passed = passed && (word[i] == 'T'); ++c; if (c == chunk) { if (passed) { ++total; } c = 0; passed = true; } } printf("%d\n", total); return 0; } |