Infinite Calendar
Hard
calendar
date-calculation
leap-year
math
Problem Description
Given a year and day difference, compute the resulting date without using built-in date libraries. Handle leap years, month lengths, and year transitions correctly.
Input Format
Three integers: year, month, day, then number of days to add.
Output Format
Resulting date in YYYY-MM-DD format.
Constraints
• 1 ≤ year ≤ 9999
• Valid starting date
• -10000 ≤ day difference ≤ 10000
• Handle leap years correctly
• No built-in date libraries allowed
Sample Input/Output
Input:
2024 2 28 2
Output:
2024-03-01
Explanation
Starting from 2024-02-28, adding 2 days: 2024-02-29 (leap year), then 2024-03-01.
Solution Hints
160
Points
Points
3000ms
Time Limit
Time Limit
256MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now