Previous date
Time: 1 s · Memory: 256 MB
- Functions
Statement
You are given a date: day , month , year . Write a function PrevDate(d, m, y) that returns the date of the previous day. Helper functions are useful: IsLeapYear(y) — is the year a leap year, MonthDays(m, y) — the number of days in a month.
A leap year is divisible by , but among years divisible by only those divisible by are leap years. February has days in a leap year and otherwise.
Input format
A single line with three integers , , — a valid date ().
Output format
A single line with three numbers: the day, month and year of the previous day.
Examples
Input
1 3 2004
Output
29 2 2004
Input
1 1 2007
Output
31 12 2006
Note
Three cases: — the day minus one; , — the last day of the previous month (given by MonthDays); January — December of the previous year. In the first example: 29 2 2004 ( is a leap year).
