Amazing Images
InterviewTime limit0.6sMemory limit1024 MB
Count the colorings of an M by N pixel grid where every K consecutive columns include a column with at least F black pixels, modulo 1,000,000,007.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Prefix sum, Combinatorics
- Solved
- No attempts yet
Problem
Fourier has an image of pixels ( lines, columns). All the pixels are initially white. Fourier wants to color some pixels black to obtain an amazing image. He considers an image amazing if, in every contiguous group of pixel columns, at least one column contains at least black pixels.
Fourier wants to know how many ways he can color the image, and he asks you to compute this count.
Input
The input contains a single line with four integers , , , and , in that order.
Output
Print a single integer, the number of amazing images modulo 1,000,000,007.
Constraints