#include #include #include int sum_day_number(int day) { std::string day_str(std::to_string(day)); int result = 0; for (auto i = day_str.begin(); i != day_str.end(); i++) { result += (*i - '0'); } return result; } int main(int argc, char *argv[]) { std::map month_and_days({ {1, 31}, {2, 28}, {3, 31}, {4, 30}, {5, 31}, {6, 30}, {7, 31}, {8, 31}, {9, 30}, {10, 31}, {11, 30}, {12, 31} }); int happy_days = 0; for (auto month_entry: month_and_days) { int month = month_entry.first; int days = month_entry.second; for (int j = 1; j < days; j++) { if (month == sum_day_number(j)) { happy_days++; } } } std::cout << happy_days << std::endl; return 0; }