#abc242e. E - (∀x∀)
E - (∀x∀)
Score : points
问题描述
对于 个测试用例,解决以下问题。
给定一个整数 和一个字符串 ,求满足以下所有条件的字符串 的个数,结果对 取模。
- 是一个长度为 的由大写英文字母组成的字符串。
- 是回文串。
- 按字典序排列时,。
- 即 或者 在字典序上小于 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Solve the following problem for test cases.
Given an integer and a string , find the number of strings that satisfy all of the conditions below, modulo .
- is a string of length consisting of uppercase English letters.
- is a palindrome.
- in lexicographical order.
- That is, or is lexicographically smaller than .
Constraints
- is an integer between and (inclusive).
- In a single input, the sum of over the test cases is at most .
- is a string of length consisting of uppercase English letters.
Input
Input is given from Standard Input in the following format:
Here, represents the -th test case.
Each test case is in the following format:
Output
Print lines. The -th line should contain the answer for the -th test case as an integer.
Sample Input 1
5
3
AXA
6
ABCZAZ
30
QWERTYUIOPASDFGHJKLZXCVBNMQWER
28
JVIISNEOXHSNEAAENSHXOENSIIVJ
31
KVOHEEMSOZZASHENDIGOJRTJVMVSDWW
Sample Output 1
24
29
212370247
36523399
231364016
This input contains five test cases.
Test case #1:
The strings satisfying the conditions are AAA
ABA
ACA
AXA
.
Test case #2:
may not be a palindrome.
Test case #3:
Be sure to find the count modulo .
update @ 2024/3/10 10:25:36