提交时间:2023-08-14 20:49:13

运行 ID: 98424

#include<bits/stdc++.h> #define int long long using namespace std; const int N=2e5+5; int a[N],ans,n,add[N],m,che; signed main(){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>n; for(int i=1;i<=n;++i){ cin>>a[i]; int x=a[i]; while(x>0) ans+=x%10,x/=10; } ans*=2*n; for(int i=1;i<=16;++i){ int k=1; for(int j=1;j<=i;++j) k*=10; for(int j=1;j<=n;++j) add[j]=a[j]%k; sort(add+1,add+n+1); int now=n; for(int j=1;j<=n;++j){ while(add[now-1]+add[j]>=k) now--; if(add[now]+add[j]>=k) ans-=(n-now+1)*9; } } cout<<ans<<endl; return 0; }