abc353D
作者:
Air1222
,
2024-10-09 21:22:18
,
所有人可见
,
阅读 4
//题目回忆:给定一串序列,要求两两合并,求最后结果%MOD
//不好算时,一定考虑贡献法,每一个数对答案的共享为,(a1+a2..+a[i-1])*10^g(a[i])+(i-1)*a[i];
//因此前缀和优化即可
//注意每一步都要取模,不然数太大,每一步都会爆
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 3e5+10,MOD = 998244353;
typedef long long LL;
LL n;
LL a[N];
int c[N];
LL s[N];
LL sum;
int cale(int x)
{
int res=0;
while(x)
{
x/=10;
res++;
}
return res;
}
LL p(int x)
{
LL res=1;
while(x)
{
res=res*10%MOD;
x--;
}
return res;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
s[i]=(s[i-1]+a[i])%MOD;
c[i]=cale(a[i]);
}
LL sum=0;
for(int i=2;i<=n;i++)
sum=(sum+(s[i-1]*(LL)p(c[i]))%MOD+((LL)(i-1)*a[i])%MOD)%MOD;
cout<<sum;
}