A billing system prorates subscription charges based on the exact number of days in a customer's billing month. Given a year and a month number, determine how many days that month contains, following the standard (proleptic) Gregorian calendar leap-year rule: a year is a leap year if it is divisible by 4, except that a year divisible by 100 is not a leap year unless it is also divisible by 400.
A single line containing two integers year month separated by a space.
Print a single integer: the number of days in that month of that year.
1 <= year <= 99991 <= month <= 12Example 1
Input
1992 2
Expected
29
Explanation
1992 is divisible by 4 and not divisible by 100, so it is a leap year, giving February 29 days.
Example 2
Input
1900 2
Expected
28
Explanation
1900 is divisible by 100 but not by 400, so despite being divisible by 4 it is NOT a leap year, giving February 28 days.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →