Topic Portal (internal title 130)
Input Format
A first line integer $ n $, represents the length of the string.
The second row contains only lowercase string $ s $.
Output Format
A row of integer result of the answer to the $ 998,244,353 $ modulo.
Sample
Sample input:
2 of
a
Sample output:
625
Data range and tips
For $ 20 \% $ test data, $ n \ leqslant 4 $.
For $ 40 \% $ test data, $ n \ leqslant 100 $.
For $ 60 \% $ test data, $ n \ leqslant 10,000,000 $.
Further test data for $ 20 \% $ ensure $ s $ $ A $ consisting only of.
Test data for $ 100 \% of $, $ 2 \ leqslant n \ leqslant 10,1 \ leqslant | s | \ leqslant 1,000,000 $.
For $ 100 \% $ test data, $ | s | \ leqslant n $.
answer
They told me that hit the table to find a law ......
Anyway, I did not find out.
The answer is:
$$26^n-26^{(n-s)}-s\times 25\times 26^{(n-s-1)}$$
Time complexity: $ \ Theta (\ log n) $.
Expectations score: $ 100 $ points.
Actual score: $ 100 $ points.
Code time
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
long long n,s;
char ch[1000001];
long long ans;
long long qpow(long long x,long long y)
{
if(y<0)return 0;
long long res=1;
while(y)
{
if(y&1)res=res*x%mod;
x=x*x%mod;
y>>=1;
}
return res;
}
int main ()
{
scanf("%lld%s",&n,ch+1);
s=strlen(ch+1);
ans = ((qpow (26, n) -qpow (26 ns) + v)% s on-* 25% * against qpow (26, ns-1)% v + v)% v;
printf("%lld",ans);
return 0;
}
rp ++