一道维护贡献的好题 见代码
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include<bits/stdc++.h> using namespace std; //input by bxd #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define repp(i,a,b) for(int i=(a);i>=(b);--i) #define RI(n) scanf("%d",&(n)) #define RII(n,m) scanf("%d%d",&n,&m) #define RIII(n,m,k) scanf("%d%d%d",&n,&m,&k) #define RS(s) scanf("%s",s) #define ll long long #define see(x) (cerr<<(#x)<<'='<<(x)<<endl) #define pb push_back #define inf 0x3f3f3f3f #define CLR(A,v) memset(A,v,sizeof A) typedef pair<int,int>pii; // const int N=1e5+10; const ll mod=998244353; ll val[N],x,p10[N],ans; ll len[N],n; ll cal(ll x) { ll len=0; while(x) { val[len+1]+=x%10; len++;x/=10; } return len; } ll sol() { cin>>n; rep(i,1,n)scanf("%lld",&x),len[i]=cal(x); p10[0]=1; rep(i,1,63)p10[i]=10*p10[i-1]%mod; repp(j,31,1)//枚举一个长度为的串 遍历1-n 判断其贡献 rep(i,1,n) { if(len[i]>=j) ans=(ans+p10[(j-1)*2]*11%mod*val[j]%mod)%mod; else ans=(ans+p10[len[i]+j-1]*2%mod*val[j]%mod)%mod; } return ans; } int main() { printf("%lld",sol()); }