結果
| 問題 |
No.188 HAPPY DAY
|
| コンテスト | |
| ユーザー |
mumucoder
|
| 提出日時 | 2018-10-27 13:59:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 745 bytes |
| コンパイル時間 | 577 ms |
| コンパイル使用メモリ | 67,420 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-19 06:49:00 |
| 合計ジャッジ時間 | 912 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 |
ソースコード
#include <iostream>
#include <map>
#include <string>
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<int, int> 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;
}
mumucoder