#include <bits/stdc++.h> using namespace std; #if DEBUG #define LOG(...) printf(__VA_ARGS__) #else #define LOG(...) #endif int main() { int n; scanf("%d", &n); char tests[n + 1]; scanf("%s", tests); int score = 0; int strike = 0; int per_test = n / 10; for (int i = 0; i < n; i++) { if (tests[i] == 'T') strike++; else strike = 0; if ((i + 1) % per_test == 0) { if (strike == per_test) score++; strike = 0; } } printf("%d\n", score); }
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 | #include <bits/stdc++.h> using namespace std; #if DEBUG #define LOG(...) printf(__VA_ARGS__) #else #define LOG(...) #endif int main() { int n; scanf("%d", &n); char tests[n + 1]; scanf("%s", tests); int score = 0; int strike = 0; int per_test = n / 10; for (int i = 0; i < n; i++) { if (tests[i] == 'T') strike++; else strike = 0; if ((i + 1) % per_test == 0) { if (strike == per_test) score++; strike = 0; } } printf("%d\n", score); } |