#include <iostream> #include <string> int main() { std::string line1; std::getline(std::cin, line1); int n = std::stoi(line1); std::string results; std::getline(std::cin, results); int numberOfTestsInGroup = n / 10; int numberOfGroups = n / numberOfTestsInGroup; int points = 0; int groupPoints; for (int group = 0; group < numberOfGroups; group++) { int startIndex = group * numberOfTestsInGroup; groupPoints = 1; for (int i = 0; i < numberOfTestsInGroup; i++) { if (results[startIndex + i] == 'N') groupPoints = 0; } points = points + groupPoints; } std::cout<<points; }
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 | #include <iostream> #include <string> int main() { std::string line1; std::getline(std::cin, line1); int n = std::stoi(line1); std::string results; std::getline(std::cin, results); int numberOfTestsInGroup = n / 10; int numberOfGroups = n / numberOfTestsInGroup; int points = 0; int groupPoints; for (int group = 0; group < numberOfGroups; group++) { int startIndex = group * numberOfTestsInGroup; groupPoints = 1; for (int i = 0; i < numberOfTestsInGroup; i++) { if (results[startIndex + i] == 'N') groupPoints = 0; } points = points + groupPoints; } std::cout<<points; } |