\(n\) 和 \(m\) 和 \(k\) 和序列 \(b_i(1\le i\le m,1\le b_i\le b_{i+1}\le \frac n2)\)。对于字符串 \(s\),如果选其 \(b_i\) 前缀和 \(b_i\) 后缀翻转并交换能变成字符串 \(s'\),则 \(s,s'\) 是相等的。求有多少个长度为 \(n\) 的字符串,字符集大小为 \(k\),互不相等。答案 \(\bmod 998244353\)。
数据范围:\(2\le n\le 10^9\),\(1\le m\le \min(\frac n2,2\cdot 10^5)\),\(1\le k\le 10^9\)。
听神仙说这是群论的 \(\tt Polya\),但是小蒟蒻没有听说过,但是手推出来了。
既然蒟蒻啥都不会,那么就慢慢做这题。
- 先解决 \(m=1\) 的情况:
设选的字符串为 \(\overrightarrow{a}\overrightarrow{b}\overrightarrow{c}\)。
变换后是字符串 \(\overleftarrow{c}\overrightarrow{b}\overleftarrow{a}\)。
再变化就又和原字符串一样了。
考虑组合一下:
如果 \(\overrightarrow{a}=\overleftarrow{c}\):\(k^{n-b_1}\) 种。
如果 \(\overrightarrow{a}\not=\overleftarrow{c}\):\((k^n-k^{n-b_1})\cdot 2^{-1}\) 种。
扫描二维码关注公众号,回复:
11280406 查看本文章
未完待续
#include <bits/stdc++.h>
using namespace std;
//Start
typedef long long ll;
typedef double db;
#define mp(a,b) make_pair(a,b)
#define x first
#define y second
#define b(a) a.begin()
#define e(a) a.end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
//Data
const int N=2e5;
const int mod=998244353;
int n,m,k,b[N+7];
//Pow
int Pow(int a,int x){
if(!a) return 0; int res=1;
for(;x;a=(ll)a*a%mod,x>>=1)if(x&1) res=(ll)res*a%mod;
return res;
}
//Main
int main(){
scanf("%d%d%d",&n,&m,&k),k%=mod;
for(int i=1;i<=m;i++) scanf("%d",&b[i]);
int res=1;
for(int i=1;i<=m;i++) res=(ll)res*(Pow(k,b[i]-b[i-1])+1)%mod;
res=(ll)res*Pow(k,n-b[m])%mod;
res=(ll)res*Pow(Pow(2,m),mod-2)%mod;
printf("%d\n",res);
return 0;
}