Problem 803
Days in a Month
Easy · 10 pts · Basics, Conditionals
Problem
Given a month M (1 for January to 12 for December) and a year Y, print how many days that month has. April, June, September and November have 30 days; February has 29 days in a leap year and 28 otherwise; all other months have 31. A year is a leap year if it is divisible by 4 but not by 100, or if it is divisible by 400.
Input
A single line with two integers M and Y.
Output
Print the number of days in month M of year Y.
Constraints
1 <= M <= 12; 1 <= Y <= 10^6
Example input
2 2024
Example output
29
Explanation
February 2024 is in a leap year (2024 is divisible by 4 and not by 100), so it has 29 days.