← RoseCode

ROSECODE 531

Every day is a holiday revisited

liuguangxi · Math ·

On planet J, a year lasts for D days. Holidays are defined by the two following rules.
1. At the beginning of the reign of the current Emperor, his birthday is declared a holiday from that year onwards.
2. If both the day before and after a day d are holidays, then d also becomes a holiday.

Initially there are no holidays. Let f(n,d) be the number of methods such that all the days of the year are holidays after exactly d days, with the year lasts for n days.

You are given f(4,2)=4, f(10,5)=240, f(50,100)mod1000000007=263154905.

Find f(1000,1012)mod1000000007.
Thanks to baihacker for the idea.

This problem was inspired by Problem 645 at Project Euler (https://projecteuler.net/problem=645)