#abc358e. E - Alphabet Tiles
E - Alphabet Tiles
Score : points
问题陈述
AtCoder Land出售写有英文字母的瓷砖。高桥正在考虑通过排列这些瓷砖来制作一个名牌。
找出满足以下条件的由大写英文字母组成的字符串的数量,长度在到之间(包括两端),对取模:
- 对于每个满足的整数,以下条件成立:
- 让是按字典顺序排列的第个大写英文字母。例如,
A
,E
,Z
。 - 字符串中的出现次数在到之间(包括两端)。
- 让是按字典顺序排列的第个大写英文字母。例如,
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
AtCoder Land sells tiles with English letters written on them. Takahashi is thinking of making a nameplate by arranging these tiles in a row.
Find the number, modulo , of strings consisting of uppercase English letters with a length between and , inclusive, that satisfy the following conditions:
- For every integer satisfying , the following holds:
- Let be the -th uppercase English letter in lexicographical order. For example,
A
,E
,Z
. - The number of occurrences of in the string is between and , inclusive.
- Let be the -th uppercase English letter in lexicographical order. For example,
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2
2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sample Output 1
10
The strings that satisfy the conditions are A
, B
, C
, AA
, AB
, AC
, BA
, BC
, CA
, CB
.
Sample Input 2
358
1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sample Output 2
64
Sample Input 3
1000
1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000
Sample Output 3
270274035