Problem E
Test instructions
Poke here
string of length $n$, string character set is $a$
There is also a sequence $b$, the number of elements is $m$, guaranteed $b_{1}<b_{2}<...<b_{m}$
Now define an operation, each time you can choose a $b_{i}$, so that the string is flipped first, and then $b_{i}$ in addition to the front and back $b_{i}$ the string back.
Defines two strings equal when a string passes through several operations that can become another string.
Find out how many strings in a string of length $n$ are essentially different.
$n, A<=1e9,m<=min\{n/2,2e5 \}$
Exercises
Analog Dafa Good!!
After several operations, the simulation operation can be found
① the $i$ character may only be in the $i$ or $n-i+1$ position of the Section
② $B _{i}$ is divided into $m$ segments, the same state must be the same (either flipped or not flipped)
③ the state of the $m $ segment can be any non-impact (starting from the largest part of the paragraph and so on can operate all scenarios)
That is, each paragraph is independent. So the answer is the multiplication of the different schemes of each paragraph.
The number of scenarios with a length of $len$ is $\frac{a^{2*len}+a^{len}}{2}$
1#include <bits/stdc++.h>2 Const intm=2e5+5;3 Const intp=998244353;4 intB[m],n,m,a;5 intPow (intXinty) {6 intres=1;7 while(y) {8 if(y&1) res=1ll*res*x%P;9x=1ll*x*x%P;Teny>>=1; One } A returnRes; - } - intMain () { the //freopen ("Data.txt", "R", stdin); -scanf" %d%d%d",&n,&m,&A); - inti,res=1, Len,inv=pow (2, P-2); - for(i=1; i<=m;i++) scanf ("%d",&b[i]); +b[0]=0; - for(i=m;i>=1; i--){ +len=b[i]-b[i-1]; Ares=1ll* (Pow (A,2*len) +pow (A,len))%p*inv%p*res%P; at } -Res=1ll*res*pow (a,n-2*B[M])%P; -printf"%d\n", res); -}
View Code
Codeforces Educational codeforces Round