結果
問題 | No.188 HAPPY DAY |
ユーザー | f843nmfwisfeuw |
提出日時 | 2020-07-25 16:56:23 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,556 bytes |
コンパイル時間 | 1,017 ms |
コンパイル使用メモリ | 90,868 KB |
実行使用メモリ | 4,376 KB |
最終ジャッジ日時 | 2023-09-09 16:49:50 |
合計ジャッジ時間 | 1,320 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
コンパイルメッセージ
main.cpp: 関数 ‘int lastDayOfMonth(int, int)’ 内: main.cpp:55:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type] 55 | } | ^
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include <stack> #include <algorithm> #include <string> #include <map> #include <iterator> #include <set> #include <queue> using namespace std; int lastDayOfMonth(int year, int month) { if (month == 2) { if (year % 400 == 0) { return 29; } else if (year % 100 == 0) { return 28; } else if (year % 4 == 0) { return 29; } else { return 28; } } else { switch (month) { case 1: return 31; case 3: return 31; case 4: return 30; case 5: return 31; case 6: return 30; case 7: return 31; case 8: return 31; case 9: return 30; case 10: return 31; case 11: return 30; case 12: return 31; } } } int daySum(int day) { if (day >= 10) { return day / 10 + day % 10; } else { return day; } } int main() { int count = 0; for (int month = 1; month <= 12; ++month) { int lastDay = lastDayOfMonth(2015, month); for (int day = 1; day <= lastDay; ++day) { if (month == daySum(day)) { count += 1; } } } cout << count << endl; return 0; }