-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfriday.cpp
34 lines (31 loc) · 820 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
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
int main(){
ifstream fin("friday.in");
ofstream fout("friday.out");
int N; fin >> N;
int months[12] = {31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, day = 2, week[7];
fill(week, week + 7, 0);
day += 12;
day %= 7;
week[day]++;
FOR(i, 1900, 1900 + N){
FOR(j, 0, 12){
if(months[j] == -1){
if(i % 4 == 0 && (i % 100 != 0 || i % 400 == 0))
day += 29;
else
day += 28;
}else
day += months[j];
day %= 7;
week[day]++;
}
}
week[day]--;
FOR(i, 0, 6)
fout << week[i] << " ";
fout << week[6] << endl;
return 0;
}