How many sequences
All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Consider the sequence of K natural numbers: a1, a2, ..., aK. Tooru thinks that this sequence is nice if and only if:
- a1+a2+...+aK = N
- a1 < a2 < ... < aK
- ai+1 - ai <= D for every natural i, smaller than K
- a1 <= D
You are given N, K and D. Please, count the number of nice sequences for her. This number can be huge, so we ask you to output it modulo 109+7.
The first and only line of the input consists of the integers N, K and D, separated by a single space.
Output the number of nice sequences on the first line of the output modulo 109+7.
Input: 10 4 1 Output: 1
The only suitable sequence is (1, 2, 3, 4).
1 <= N, K, D <= 10 : 17 points.
1 <= N, K, D <= 400 : 23 points.
1 <= N, K, D <= 2000 : 20 points.
1 <= N, K, D <= 105 : 40 points.
|Tags||dynamic-programming, easy-medium, ltime10, xcwgf666|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.