SIM10 | I. KSumT

This was the problem page during the contest. Access the current page here.
Time limit: 1s Memory limit: 256MB Input: Output:

Tutz likes math problems; this time he is trying to solve the following problem:

You are given KK, SS, TT and are asked how many sequences of KK integers (more formally a1a_1, a2a_2, a3a_3, \cdots, aKa_K) follow these rules:

  • ai>0a_i > 0, for any ii (1iK1 \leq i \leq K)
  • a1+a2+a3++aK=Sa_1 + a_2 + a_3 + \cdots + a_K = S
  • All subarrays of length TT have the same product. More formally, a1a2a3  aT=a2a3a4  aT+1==aKT+1aKT+2aKT+3  aKa_1 \cdot a_2 \cdot a_3 \cdot \ \dots \ \cdot a_T = a_2 \cdot a_3 \cdot a_4 \cdot \ \dots \ \cdot a_{T+1} = \dots = a_{K-T+1} \cdot a_{K-T+2} \cdot a_{K-T+3} \cdot \ \dots \ \cdot a_K

You should find the number of such arrays modulo 109+710^9 + 7 (109+710^9 + 7 is a prime number).

Input data

The first line contains 33 integers KK, SS, TT (1K,S,T51061 \leq K, S, T \leq 5 \cdot 10^6, KTK \geq T).

Output data

Output one integer — the number of possible sequences modulo 109+710^9 + 7

Example 1

stdin

5 13 3

stdout

15

Explanation

The 1515 sequences in the first example are:
[1,1,9,1,1][1, 1, 9, 1, 1] , [1,2,7,1,2][1, 2, 7, 1, 2] , [1,3,5,1,3][1, 3, 5, 1, 3] , [1,4,3,1,4][1, 4, 3, 1, 4] , [1,5,1,1,5][1, 5, 1, 1, 5] , [2,1,7,2,1][2, 1, 7, 2, 1] , [2,2,5,2,2][2, 2, 5, 2, 2] , [2,3,3,2,3][2, 3, 3, 2, 3] , [2,4,1,2,4][2, 4, 1, 2, 4] , [3,1,5,3,1][3, 1, 5, 3, 1] , [3,2,3,3,2][3, 2, 3, 3, 2] , [3,3,1,3,3][3, 3, 1, 3, 3] , [4,1,3,4,1][4, 1, 3, 4, 1] , [4,2,1,4,2][4, 2, 1, 4, 2] , [5,1,1,5,1][5, 1, 1, 5, 1]

Example 2

stdin

15 44 9

stdout

1162800

Log in or sign up to be able to send submissions!