Problem Description
India and Pakistan are playing a bilateral series of A matches. Now, you know that India won exactly B matches. We know that there are ACB ways in which India could win B out of the A matches played. Here NCR is the number of ways to choose R objects out of N objects.
Having known that we want to know the number of possible results in which the maximum consecutive number of matches lost
by India is exactly K.
We need to find that count for all K from 1 to A-B.
Since the answer can be large, calculate it modulo 109 + 7.
1 <= B < A <= 5 x 105
Return an array of length A - B, the ith element denotes the number of possible results in which maximum consecutive losses is exactly equal to i.
Since the answer can be large, calculate it modulo 109 + 7.
Input 1:
A : 5 B : 2
Input 2:
A : 4 B : 1
Output 1:
[1, 6, 3]
Output 2:
[0, 2, 2]
Explanation 1:
Let's denote a win by W and a defeat by L. So, possible number of ways in which India could win 2 out of 5 matches are- 1. WWLLL - Maximum 3 consecutive losses 2. WLWLL - Maximum 2 consecutive losses 3. WLLWL - Maximum 2 consecutive losses 4. WLLLW - Maximum 3 consecutive losses 5. LWWLL - Maximum 2 consecutive losses 6. LWLWL - Maximum 1 consecutive loss 7. LWLLW - Maximum 2 consecutive losses 8. LLWWL - Maximum 2 consecutive losses 9. LLWLW - Maximum 2 consecutive losses 10. LLLWW - Maximum 3 consecutive losses
Explanation 2:
Possible outcomes are- 1. WLLL - Maximum 3 consecutive losses 2. LWLL - Maximum 2 consecutive losses 3. LLWL - Maximum 2 consecutive losses 4. LLLW - Maximum 3 consecutive losses
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.