#CCBCMCHIN0000063. Ngày trước đó (Previous Calendar Date)
Ngày trước đó (Previous Calendar Date)
Previous Calendar Date
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given a valid Gregorian date, output the immediately previous date. Decrease the day if possible; otherwise move to the last day of the previous month, or December 31 of the previous year for January 1. Input year is at least 2.
Input
One line contains three integers d,m,y in that order.
Output
Print the resulting day, month and year separated by spaces.
Subtasks
-
Subtask 1 (20 points): Day d >= 2 on a valid date, with 2 <= y <= 9999.
-
Subtask 2 (30 points): Month is neither January nor March, valid date, year 2..9999.
-
Subtask 3 (50 points): Any valid date, year 2..9999.
Examples
Example 1
Input
1 3 2024
Output
29 2 2024
Explanation
For this input, the case-specific computation and the required exact output are shown above. When moving back from March 1 in the leap year 2024, the previous month is February with 29 days.
Example 2
Input
1 1 2001
Output
31 12 2000
Explanation
For this input, the case-specific computation and the required exact output are shown above. When moving back from January 1, the previous date is December 31 of the previous year.