题意:给出一个字符串的长度,要求求出字符串的回文子串数量(不重复)
思路:写出n = 1, n = 2, n = 3发现规律res = 26^n, 当n >= 4时,res均等于A(3, 26) 选择三个字符进行排列 : "abca", "abcab", "abcabc" …………
代码():
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define lowbit(n) n & (-n)
#define mem(a) memset(a, 0, sizeof(a));
#define Buff ios::sync_with_stdio(false)
#define sqr(x) x*x
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>PII;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int base = 131;
const int N = 1e6+7;
int main()
{
int T;
cin >> T;
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;
}