#P1202. Friday the 13th Frequency Count

    ID: 14124 Type: Default 1000ms 256MiB

Friday the 13th Frequency Count

Friday the 13th Frequency Count

This problem asks you to determine how many times the 13th day of any month falls on each day of the week (Monday to Sunday) during a given period. In particular, you are to count the occurrences for the period from January 1, 1900 to December 31, (1900 + n - 1), where n is the number of years in the period.

Some details you need to know:

  • January 1, 1900 was a Monday.
  • Months with 30 days: April, June, September, and November. All the other months except February have 31 days.
  • February has 28 days in a common year and 29 days in a leap year.
  • A year is a leap year if it is divisible by 4. However, century years are an exception: a century year is a leap year only if it is divisible by 400. For example, 1900 is not a leap year, but 2000 is.

The weekday of the 13th day of a month is determined by the weekday of the first day of that month. If we denote the weekday by an index where Monday = 0, Tuesday = 1, ..., Sunday = 6, then the weekday for the 13th is given by:

$\text{weekday}_{13} = (\text{first_day_of_month} + 12) \mod 7$

Your task is to calculate and output the frequencies (separated by a space) that the 13th falls on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday (in that order) during the given period.

inputFormat

The input consists of a single integer n ($1 \leq n \leq 400$), indicating the number of years starting from 1900.

outputFormat

Output 7 space‐separated integers. Each integer represents the count of months in which the 13th falls on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday, respectively.

sample

1
1 3 1 2 2 2 1