-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path19.cpp
More file actions
40 lines (39 loc) · 717 Bytes
/
19.cpp
File metadata and controls
40 lines (39 loc) · 717 Bytes
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
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <cstdio>
int main() {
int day = 1;
int y = 1900;
int m = 1;
int d = 1;
int ans = 0;
auto leap = [&]() {return (y % 4 == 0) && ((y % 1000 != 0) || (y % 400 == 0));};
while (y != 2001) {
if (y > 1900 && day == 7 && d == 1) ++ans;
++d;
if (d < 29) {
day = day % 7 + 1;
continue;
}
bool over = false;
if (m == 2) {
if ((leap() && d == 30) || (!leap() && d == 29)) {
over = true;
}
} else if ((m == 4 || m == 6 || m == 9 || m == 11) && d == 31) {
over = true;
} else if (d == 32) {
over = true;
}
if (over) {
d = 1;
++m;
if (m == 13) {
m = 1;
++y;
}
}
day = day % 7 + 1;
}
std::cout << ans << std::endl;
return 0;
}