結果
| 問題 | No.188 HAPPY DAY |
| コンテスト | |
| ユーザー |
f843nmfwisfeuw
|
| 提出日時 | 2020-07-25 16:56:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,556 bytes |
| コンパイル時間 | 815 ms |
| コンパイル使用メモリ | 91,968 KB |
| 実行使用メモリ | 6,816 KB |
| 最終ジャッジ日時 | 2024-06-27 09:33:47 |
| 合計ジャッジ時間 | 1,126 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 |
コンパイルメッセージ
main.cpp: In function 'int lastDayOfMonth(int, int)':
main.cpp:55:1: warning: control reaches end of non-void function [-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;
}
f843nmfwisfeuw