← 返回 optiver 的题目列表Number of Days Between Two Dates
类型:online_judge
Problem: Number of Days Between Two Dates
Given two date strings date1 and date2 in the format YYYY-MM-DD, return the absolute number of days between the two dates.
Input Format
Read two date strings from standard input. They may appear on one line or on two lines:
date1 date2
Output Format
Print one integer: the absolute difference in days between the two dates.
Constraints
1971-01-01 <= date1, date2 <= 2100-12-31
Both dates are valid.
Leap years must be handled correctly:
A year divisible by 400 is a leap year.
A year divisible by 100 but not by 400 is not a leap year.
A year divisible by 4 but not by 100 is a leap year.
Example
Input:
2019-06-29 2019-06-30
Output:
1
Example
Input
2019-06-29 2019-06-30
Output
1