Task Gift Page 1 of 2
Task Gift Page 1 of 2
Task
Write a program gift to help Polly by solving the following problem: Given K – the
maximum length of the simple sequences that Polly can buy, and N – the length of the
interesting sequence that she wants to form, calculate how many different interesting
sequences she could make. Since this number can be very large, output it modulo
1,000,000,007.
Input
Two numbers separated by space are given on the first line of the standard input – N
and K, respectively.
Output
You should output a single number on the first line of the standard output – the
number of different interesting sequences Polly can make with the current constraints.
Output the answer modulo 1,000,000,007.
Constraints
1 ≤ K ≤ N ≤ 2 000 000
In 20% of the tests: 1 ≤ N ≤ 20
In 50% of the tests: 1 ≤ N ≤ 2 000
Task Gift
Page 1 of 2
EJOI Training contest
Task Gift (English)
Example
Sample input Sample output
43 7
11 5 912
55 35 377876174
Explanation of the example 1 :Let K=3 and N=4. The possible interesting sequences
are {0,0,0,0}; {0,0,0,1}; {0,0,1,0}; {0,0,1,2}; {0,1,0,0}; {0,1,0,1}; {0,1,2,0}. Hence there are 7
sequences and this is the answer for this example.
Task Gift
Page 2 of 2