Problem 559
Day of the Week
Easy · 10 pts · Math
Problem
Given a date as day D, month M and year Y in the Gregorian calendar, print the day of the week it falls on. Remember the leap-year rule: a year is a leap year if it is divisible by 4, except years divisible by 100, unless they are also divisible by 400. You can count the days since a known reference date, or use Zeller's congruence. The date is always valid.
Input
A single line with three integers D, M and Y.
Output
Print the weekday name: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday or Sunday.
Constraints
1600 <= Y <= 2400; 1 <= M <= 12; D is a valid day of month M in year Y
Example input
31 8 2019
Example output
Saturday
Explanation
1 January 2019 was a Tuesday. 31 August 2019 is day 243 of that year, 242 days later, which is 34 weeks and 4 days. Tuesday plus 4 days is Saturday.