题目描述
题目分析
简单枚举,对于+2的情况特判即可
cpp
#include<bits/stdc++.h>
using namespace std;
int num, ans, flag;
int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool is_ren(int n)
{
if((n % 4 == 0 && n % 100 != 0) || n % 400 == 0)return true;
return false;
}
int main()
{
for(int i = 2000; i <= 2020; i ++)
{
if(is_ren(i))m[2] = 29;
else m[2] = 28;
for(int j = 1; j <= 12; j ++)
{
for(int k = 1; k <= m[j]; k ++)
{
num ++;
if(k == 1 || (num % 7 - 3) == 0)ans += 2;
else ans += 1;
if(i == 2020 && j == 10 && k == 1)
{
flag = 1;
break;
}
}
if(flag)break;
}
if(flag)break;
}
cout << ans;
return 0;
}