-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfriday.cpp
60 lines (51 loc) · 910 Bytes
/
friday.cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
ID: cl34nc0d3r
LANG: C++
TASK: friday
*/
#include <fstream>
using namespace std;
int main()
{
ifstream fin("friday.in");
ofstream fout("friday.out");
int week[7] = {0};
/* Sat is new Mon
* [Mon, Tue, Wen, Th, Fr, Sat, Sun] >> 2
* [Sat, Sun, Mon, Tue, Wen, Th, Fr]
*/
int day = 2;
int n;
fin >> n;
for (int y = 1900; y < 1900 + n; y++)
{
for (int m = 0; m < 12; m++)
{
week[(day + 12) % 7]++;
switch (m)
{
case 3:
case 5:
case 8:
case 10:
day += 30;
break;
case 1:
day += 28 + (y % 4 == 0 && y % 100 || y % 400 == 0);
break;
default:
day += 31;
break;
}
}
}
int week_len = sizeof(week) / sizeof(week[0]);
for (int i = 0; i < week_len; i++)
{
fout << week[i];
if (i < week_len - 1)
fout << ' ';
else
fout << endl;
}
}