2020hdu多校 1004Distinct Sub-palindromes

题目

在这里插入图片描述

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6754

思路

只要有ababababa这种形式一定会有子回文串 且子回文串长度为n 要打破这种局面 就只有abcabcabc
所以分类讨论即可

代码

#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod=998244353;
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	cin>>t;
	int m=26*25*24%mod;
	while(t--){
		int n;
		cin>>n;
		if(n==1) cout<<26<<endl;
		else if(n==2) cout<<26*26<<endl;
		else if(n==3) cout<<26*26*26<<endl;
		else cout<<26*25*24<<endl;
	}
    return 0;
}

猜你喜欢

转载自blog.csdn.net/kosf_/article/details/107500029