Problem hidden
RECCSOLV - Recursion Solver
You are given a recursion in the following form -
f(n) = c1f(n-1) + c2f(n-2) + ... + ckf(n-k)
And the base cases f(0), f(1), ..., f(k-1)
Given a number n. Find f(n). As the number can be very big. Output f(n) mod 109+9
Input
First line contains the recursion. f(n) = c1f(n-1) + c2f(n-2) + ... + ckf(n-k). (ci <= 10000, k <= 9)
If any ci = 1, it will not be shown.
The next line contains the base cases f(0), f(1), ... , F(k-1)
Next line will contain a number t (t<= 100000) the number testcases.
Next t lines will contain a number n (n<= 232-1)
Output
Print f(n) mod 109 + 9
Example
Input: f(n) = 2f(n-1) + f(n-2)
0 1
1
5
Output:
29
Added by: | Rezwan |
Date: | 2016-05-14 |
Time limit: | 3s-4s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY |