#include <iostream> #include <sstream> void prog_main(std::istream& in, std::ostream& out) { int num = 0; in >> num; int round = num / 10; char c; int j = 0; bool good = true; int good_cnt = 0; for (int i = 0; i < num; i++) { in >> c; if (c == 'N') { good = false; } if (j == round - 1) { if (good) { good_cnt++; } } if (j == round - 1) { j = 0; good = true; } else { j++; } } out << good_cnt << "\n"; } #ifndef TEST int main(int argc, char* argv[]) { prog_main(std::cin, std::cout); return 0; } #endif
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 34 35 36 37 38 39 40 41 42 43 | #include <iostream> #include <sstream> void prog_main(std::istream& in, std::ostream& out) { int num = 0; in >> num; int round = num / 10; char c; int j = 0; bool good = true; int good_cnt = 0; for (int i = 0; i < num; i++) { in >> c; if (c == 'N') { good = false; } if (j == round - 1) { if (good) { good_cnt++; } } if (j == round - 1) { j = 0; good = true; } else { j++; } } out << good_cnt << "\n"; } #ifndef TEST int main(int argc, char* argv[]) { prog_main(std::cin, std::cout); return 0; } #endif |