// No.188 HAPPY DAY // https://yukicoder.me/problems/no/188 // #include #include using namespace std; bool is_happy_day(int mm, int dd); int main() { int hit = 0; for (auto mm = 1; mm <= 12; mm++) { for (auto dd = 1; dd <= 31; dd++) { if (mm == 4 || mm == 6 || mm == 9 || mm == 11) { if (dd > 30) continue; } else if (mm == 2) { if (dd > 28) continue; } if (is_happy_day(mm, dd)) { // cout << mm << "/" << dd << endl; hit++; } } } cout << hit << endl; } bool is_happy_day(int mm, int dd) { int dd_total = 0; while (dd > 0) { dd_total += (dd % 10); dd /= 10; } return mm == dd_total; }