#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
const int MOD = 1e9 + 7;
// 判断是否是闰年
bool isLeapYear(int year) {
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
// 获取某个月份的天数
int getDaysInMonth(int year, int month) {
switch (month) {
case 2:
return isLeapYear(year) ? 29 : 28;
case 4: case 6: case 9: case 11:
return 30;
default:
return 31;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int cnt = 0; // 计数器
int today = 6; // 2000年1月1日是星期六(假设)
// 遍历2000年到2020年
for (int year = 2000; year <= 2020; year++) {
// 遍历1月到12月
for (int month = 1; month <= 12; month++) {
// 遍历1日到该月的最大天数
for (int day = 1; day <= getDaysInMonth(year, month); day++, today++) {
// 如果到达2020年10月1日,输出结果并退出
if (year == 2020 && month == 10 && day == 1) {
cout << cnt + 2 << endl;
return 0;
}
// 判断条件:today % 7 == 1 或 day == 1
if (today % 7 == 1 || day == 1) {
cnt += 2;
} else {
cnt += 1;
}
}
}
}
return 0;
}
using namespace std;
#define endl '\n'
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
const int MOD = 1e9 + 7;
// 判断是否是闰年
bool isLeapYear(int year) {
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
// 获取某个月份的天数
int getDaysInMonth(int year, int month) {
switch (month) {
case 2:
return isLeapYear(year) ? 29 : 28;
case 4: case 6: case 9: case 11:
return 30;
default:
return 31;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int cnt = 0; // 计数器
int today = 6; // 2000年1月1日是星期六(假设)
// 遍历2000年到2020年
for (int year = 2000; year <= 2020; year++) {
// 遍历1月到12月
for (int month = 1; month <= 12; month++) {
// 遍历1日到该月的最大天数
for (int day = 1; day <= getDaysInMonth(year, month); day++, today++) {
// 如果到达2020年10月1日,输出结果并退出
if (year == 2020 && month == 10 && day == 1) {
cout << cnt + 2 << endl;
return 0;
}
// 判断条件:today % 7 == 1 或 day == 1
if (today % 7 == 1 || day == 1) {
cnt += 2;
} else {
cnt += 1;
}
}
}
}
return 0;
}
0 回复
0 转发
0 喜欢
1 阅读



