← 返回 optiver 的题目列表Days Between Dates (Days Between 3.0 V2)
类型:online_judge
Given two dates date1 and date2, each represented by integers year, month, day, and guaranteed that date1 is earlier than date2, compute the number of days between them (i.e., date2 - date1).
You must not use any built-in date/calendar libraries.
You may call a provided helper:
DaysInMonth(month, year): returns the number of days in the given month of year (already correctly handles leap years and month lengths).
Input (suggested)
Two lines:
Line 1: y1 m1 d1
Line 2: y2 m2 d2
Output
Print one integer: the day difference.
Constraints (suggested)
1 <= year <= 10^4
1 <= month <= 12
1 <= day <= DaysInMonth(month, year)
date1 < date2
Samples
2020 1 1
2020 1 2
Output:
1
2019 12 31
2020 1 1
Output:
1
2020 2 28
2020 3 1
Output:
2
2020 3 1
2021 3 1
Output:
365
1900 2 28
1900 3 1
Output:
1
Example
Input
2020 1 1
2020 1 2
Output
1