提交时间:2023-12-22 13:33:30
运行 ID: 117133
#include<bits/stdc++.h> using namespace std; #define rep(i,s,n)for(int i=(s);i<=(n);++i) #define all_(s,n)(s)+1,(s)+(n)+1 typedef long long ll; int n; ll a[200005],b[200005],sum=0; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin>>n; rep(i,1,n){ cin>>a[i]; ll x=a[i]; while(x!=0){ sum+=x%10; x/=10; } } sum*=2*n; for(ll i=10;i<10000000000000000ll;i*=10){//10^15 rep(j,1,n)b[j]=a[j]%i; sort(all_(b,n)); ll g=0; rep(j,1,n)g+=n-(lower_bound(all_(b,n),i-b[j])-b)+1; sum-=g*9; } cout<<sum; return 0; }