OptiverOA #3
Days Between
EasyJudge-ready
Topics (AI-labelled)Bits & MathSimulation
Given two valid dates, where the first is earlier than the second, compute the number of days elapsed between them, without using system date objects or date-difference functions.
Input
The input is six integers year1 month1 day1 year2 month2 day2. The months and days must form valid proleptic Gregorian dates, and the first date is earlier than the second. The original problem does not restrict the year; this site explicitly restricts 1≤year1,year2≤9999.
Output
Output the number of days between the two dates, not counting the start day.
Example 1
Input:
2010 5 1 2011 5 1
Output:
365
Example 2
Input:
2020 2 27 2020 3 1
Output:
3
Example 3
Input:
2019 12 31 2020 1 1
Output:
1
Example notes
Use the Gregorian leap-year rule: a year divisible by 4 is a leap year, except century years, which must also be divisible by 400. The year limit of 9999 was added by this site to keep int output safe; it is not a constraint of the original problem.
Editorial
Loading solution…