#P5407. Mother's Day

    ID: 18639 Type: Default 1000ms 256MiB

Mother's Day

Mother's Day

Mother's Day is a celebration dedicated to honoring mothers. In many parts of the world, it is celebrated on different dates. In the United States, the modern Mother's Day was established in 1913 by the US Congress, which declared the second Sunday in May as the official day of celebration. On this day, children often present their mothers with gifts such as carnations, which are considered one of the most appropriate flowers for the occasion.

Given a year, your task is to determine on which day of May Mother's Day falls. Formally, let \(W(1)\) represent the day of the week for May 1 with Sunday as \(0\), Monday as \(1\), etc. The first Sunday in May, \(S_1\), can be computed as follows:

[ S_1 = \begin{cases} 1, & \text{if } W(1)=0, \ 8 - W(1), & \text{if } W(1) \neq 0, \end{cases} ]

Mother's Day is the second Sunday of May, which is \(S_1 + 7\). Output the day (an integer) in May corresponding to Mother's Day for the given year.

inputFormat

An integer \(Y\) representing the year.

outputFormat

Output a single integer indicating the day in May on which Mother's Day falls in the year \(Y\).

sample

2023
14