0-1 Sequence

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 2.0s
Memory limit: 512M

Problem type

You are given n zeros and m ones. Your task is to find the number of ways to arrange them into one sequence such that the absolute difference between the number of zeros and the number of ones for any consecutive interval is not greater than k. Since the answer is huge, output the answer \bmod 10^9 + 7.

Input Specification

The first line contains three integers n, m and k (1 \le n \le 500, 1 \le m \le 500, 1 \le k \le 500), representing the number of zeros, the number of ones, and the maximum allowed absolute difference between zeros and ones in any interval, respectively.

Output Specification

Output a single integer representing the number of ways \bmod 10^9 + 7.

Constraints

Subtask Points Additional constraints
1 30 n \le 20, m \le 20, k \le 20
2 40 n \le 200, m \le 200, k \le 20
3 30 No additional constraints

Sample Input 1

4 2 2

Sample Output 1

4

Explanation

Given 4 zeroes and 2 ones, there are 4 ways: (0, 1, 0, 1, 0, 0), (0, 0, 1, 1, 0, 0), (0, 0, 1, 0, 1, 0), (0, 1, 0, 0, 1, 0).

Sample Input 2

1 2 1

Sample Output 2

1

Sample Input 3

4 2 1

Sample Output 3

0

Comments

There are no comments at the moment.