#P12240. SimpleCron Execution Count in 2023
SimpleCron Execution Count in 2023
SimpleCron Execution Count in 2023
This problem involves a simplified version of a Cron expression called SimpleCron. A SimpleCron expression is a string consisting of exactly 5 fields separated by a single space. The fields represent:
- Seconds (0--59)
- Minutes (0--59)
- Hours (0--23)
- Day (1--31)
- Month (1--12)
Each field can be given in one of the following formats (and only one type of special symbol is allowed per field):
*
representing all possible values in that field.- A comma-separated list (e.g.
3,20
) representing enumerated values. - A range defined by a dash (e.g.
1-5
which is equivalent to1,2,3,4,5
). - A single number.
For example, the SimpleCron expression below:
represents a task scheduled to run at 01:02:04, 03:02:04 and 15:02:04 every day. In the year 2023, since there are 365 days, the task will execute 3 \times 365 = 1095 times.
Given a valid SimpleCron expression (all numbers are provided without leading zeros), your task is to calculate the total number of times the scheduled task will execute in the year 2023. Consider the actual number of days in each month (February has 28 days in 2023, etc.).
inputFormat
The input consists of a single line containing the SimpleCron expression with exactly 5 fields separated by a single space.
Each field is one of the following:
*
indicating all valid numbers in that field.- A comma-separated list of numbers (e.g.
3,20
). - A range in the form
a-b
(e.g.1-5
). - A single integer.
outputFormat
Output a single integer which is the total number of times the task is executed in the year 2023.
sample
* * * * *
31536000