MathWorksOA #12
Good Strings
Estimated MediumJudge-ready
Topics (AI-labelled)DP Basics
Count the strings of n lowercase letters in which the absolute difference between the alphabet positions of every two adjacent letters is at most d, modulo 1,000,000,007.
This site uses a standard input/output protocol.
Input
One line with n d. Constraints added by this site: 1≤n≤100000, 0≤d≤25.
Output
Output the number of valid strings modulo 1,000,000,007.
Example 1
Input:
2 2
Output:
124
Example 2
Input:
3 5
Output:
2596
Example 3
Input:
1 0
Output:
26
Example 4
Input:
2 0
Output:
26
Editorial
Loading solution…