#include <cstdio> #include <cstdlib> int main() { char answers[256]; int numTests, groupSize, result = 0; bool ok = true; fgets(answers, 256, stdin); numTests = strtol(answers, nullptr, 10); groupSize = numTests / 10; fgets(answers, 256, stdin); for (int no=0, grNo=0; no<numTests; ++no, ++grNo) { if (grNo == groupSize) { if (ok) ++result; ok = true; grNo = 0; } if (answers[no] != 'T') ok = false; } if (ok) ++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 26 27 28 29 30 31 32 33 | #include <cstdio> #include <cstdlib> int main() { char answers[256]; int numTests, groupSize, result = 0; bool ok = true; fgets(answers, 256, stdin); numTests = strtol(answers, nullptr, 10); groupSize = numTests / 10; fgets(answers, 256, stdin); for (int no=0, grNo=0; no<numTests; ++no, ++grNo) { if (grNo == groupSize) { if (ok) ++result; ok = true; grNo = 0; } if (answers[no] != 'T') ok = false; } if (ok) ++result; printf("%d\n", result); return 0; } |