結果

問題 No.188 HAPPY DAY
ユーザー f843nmfwisfeuwf843nmfwisfeuw
提出日時 2020-07-25 17:00:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 1,023 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 90,708 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 16:59:25
合計ジャッジ時間 1,165 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) {

    int day[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    if (year % 400 == 0) {
        day[1] = 29;
    } else if (year % 100 == 0) {
        day[1] = 28;
    } else if (year % 4 == 0) {
        day[1] = 29;
    } else {
        day[1] = 28;
    }

    return day[month - 1];
}

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;
}
0