#C6922. Finding the Day of the Week

    ID: 50736 Type: Default 1000ms 256MiB

Finding the Day of the Week

Finding the Day of the Week

You are given a date represented by three integers: year, month, and day. Your task is to determine the day of the week for the given date. For example, the date October 29, 2023 corresponds to Sunday.

You may use any appropriate method to compute the day of the week. One common approach is to use Zeller's Congruence, which is given by the formula:

$$h = \left(q + \left\lfloor \frac{13(m+1)}{5} \right\rfloor + K + \left\lfloor \frac{K}{4} \right\rfloor + \left\lfloor \frac{J}{4} \right\rfloor - 2J\right) \mod 7$$

where:

  • \(q\) is the day of the month,
  • \(m\) is the month (with March = 3, April = 4, \dots, January = 13, February = 14 for the previous year),
  • \(K\) is the year of the century, and
  • \(J\) is the zero-based century.

If using built-in libraries for date manipulation is allowed, you may use them. The input ends when the triple 0 0 0 is encountered, which should not be processed.

inputFormat

The input consists of several lines. Each line contains three integers: year, month, and day, separated by spaces. The input terminates with a line containing 0 0 0, which should not be processed.

outputFormat

For each date provided (except the terminal line), output the corresponding day of the week (e.g. Sunday, Monday, etc.) on a separate line.

## sample
2023 10 29
0 0 0
Sunday

</p>