多校第一场——1004 Distinct Sub-palindromes

Problem Description
S is a string of length n. S consists of lowercase English alphabets.

Your task is to count the number of different S with the minimum number of distinct sub-palindromes. Sub-palindrome is a palindromic substring.

Two sub-palindromes u and v are distinct if their lengths are different or for some i (0≤i≤length), ui≠vi. For example, string “aaaa” contains only 4 distinct sub-palindromes which are “a”, “aa”, “aaa” and “aaaa”.

Input
The first line contains an integer T (1≤T≤105), denoting the number of test cases.

The only line of each test case contains an integer n (1≤n≤109).

Output
For each test case, output a single line containing the number of different strings with minimum number of distinct sub-palindromes.

Since the answer can be huge, output it modulo 998244353.

Sample Input
2
1
2

Sample Output
26
676

题目大意:给定字符串的长度,求用最小数量的不同子回文串组成的串数目

题解:找规律,n=1,是26,n=2是676,n=3是17576,n大于3是15600

代码:

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        switch(n)
        {
        case 1:
            cout<<26<<endl;
            break;
        case 2:
            cout<<676<<endl;
            break;
        case 3:
            cout<<17576<<endl;
            break;
        default:
            cout<<15600<<endl;
            break;
        }
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_43330910/article/details/107570165