← RoseCode

ROSECODE 121

Creatures

sinan · Programming ·

Let there be creatures with different N colors (1,..,N) for N>7. Let num(i) be the number of creatures with i-th color on a specific day.

The following events occur within an N-day period.

On the i-th day of the period;
number of cretures with i-th color increase by 1000 more than the sum of existing creatures with (i+1)-th, (i+2)-th and twice the (i+3)-th colors.
num(i)=num(i)+num(i+1)+num(i+2)+2*num(i+3)+1000;

number of ceatures with (i+4)-th color becomes 17 more than twice the existing creatures of that color.
num(i+4)=2*num(i+4)+17

All the (i+5)-th colored creatures but one change their color to i-th color (i.e. one of them doesn't change its color).

number of creatures with (i+6)-th color quadruples
num(i+6)=4*num(i+6)

Find the total number of creatures after 10^19 days if N=11 and initially there is 1 creature of each color.

Assume that the first day is the first day of the period.

Note: (i+n)-th color should mean ((i+n)-N)-th color if i+n>N. For example if i=9 then (i+4)-th should mean 2nd (9+4-11=2)

Input format: total mod 10^9
Example: 619784765 for 100th day when N=10

[My timing: <1s]