P1202 [USACO1.1] Friday the Thirteenth

Description

It is Friday the $13$th again. Does the $13$th fall on Friday less often than on other days? To answer this question, write a program that counts, for each month, how many times the $13$th falls on each day of the week. Given a period of $n$ years, compute the counts for dates from January $1$, $1900$ to December $31$, $1900 + n - 1$. Here are some things you need to know: 1. January $1$, $1900$ was a Monday. 2. Months $4$, $6$, $9$ and $11$ have $30$ days; all other months except month $2$ have $31$ days. In a leap year, February has $29$ days; in a common year, February has $28$ days. 3. A year divisible by $4$ is a leap year ($1992 = 4 \times 498$, so $1992$ is a leap year, but $1990$ is not). 4. The above rule does not apply to century years. A century year divisible by $400$ is a leap year; otherwise, it is a common year. Thus, $1700$, $1800$, $1900$, and $2100$ are common years, while $2000$ is a leap year.

Input Format

A single positive integer $n$.

Output Format

Output, in order, the counts of Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, and Friday on which the $13$th occurs. Print them on one line, separated by spaces.

Explanation/Hint

Constraints For $100\%$ of the testdata, $1 \le n \le 400$. Translation from NOCOW. USACO Training Section $1.1$. Translated by ChatGPT 5