#B3835. Determine the Number of Days in a Month

    ID: 11492 Type: Default 1000ms 256MiB

Determine the Number of Days in a Month

Determine the Number of Days in a Month

Xiaoming just learned about the number of days in each month and how to determine whether a year is a leap year or not. Your task is to write a program that, given a month and a year, outputs the number of days in that month. Remember that February has 29 days in a leap year and 28 days otherwise. For months with 31 and 30 days, use the standard calendar rules:

  • Months 1, 3, 5, 7, 8, 10, and 12 have 31 days.
  • Months 4, 6, 9, and 11 have 30 days.
  • February has 28 days in a common year and 29 days in a leap year.

A year is a leap year if and only if it is divisible by 400, or it is divisible by 4 but not by 100. Your solution should follow these rules.

inputFormat

The input consists of two space-separated integers: M (the month, where 1 ≤ M ≤ 12) and Y (the year, a positive integer).

outputFormat

Output a single integer indicating the number of days in the given month of the given year.

sample

2 2020
29