solution.cpp 639 字节
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include <bits/stdc++.h>
using namespace std;
int M[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
    int y = 2000, m = 1, d = 1, w = 6, ans = 2;
    while (y != 2020 || m != 10 || d != 1)
    {
        if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
            M[2] = 29;
        else
            M[2] = 28;
        d++;
        w = (w + 1) % 7;
        if (d > M[m])
        {
            d = 1;
            m++;
            if (m > 12)
            {
                y++;
                m = 1;
            }
        }
        if (d == 1 || w == 1)
            ans++;
        ans++;
    }
    cout << ans;
}