#CCBCHMUOI0000022. Số ngày tháng thường (Days in a Month)
Số ngày tháng thường (Days in a Month)
Days in a Month
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given month m and year y in the Gregorian calendar, months 1,3,5,7,8,10,12 have 31 days and 4,6,9,11 have 30. February has 29 days in a leap year and 28 otherwise. A leap year is divisible by 400 or divisible by 4 but not by 100.
Input
One line contains integers m and y, the month and year.
Output
Print the number of days in month m of year y.
Subtasks
- Subtask 1 (20%): m = 2, 1900 <= y <= 2024.
- Subtask 2 (30%): 1 <= m <= 12, 1900 <= y <= 2024.
- Subtask 3 (50%): 1 <= m <= 12, 1 <= y <= 9999.
Examples
Example 1
Input
2 2000
Output
29
Explanation
Year 2000 is divisible by 400, so February has 29 days.
Example 2
Input
2 1900
Output
28
Explanation
Year 1900 is divisible by 100 but not 400, so February has 28 days.