Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
98509 | CSYZChenQX | 早凉的函数2 | C++ | 运行超时 | 60 | 1000 MS | 6504 KB | 883 | 2023-08-15 18:56:26 |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MX = 2e5 + 5; int n; ll a[MX], f[MX], b[MX]; ll lans = 0, sum, x; ll ten[16] = {0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000}; inline void chai(ll a, int i) { int ret = 0; while(a) ret+=a%10, a/=10; f[i] = ret; } int main() { cin>>n; for(int i=1; i<=n; i++) { scanf("%lld", &a[i]); chai(a[i], i); lans += (2*n)*f[i]; } for(x=10; x<=1e15; x*=10) { stable_sort(a+1, a+n+1, [](ll u,ll v) {return u%x<v%x;}); for(int i=1; i<=n; ++i) b[i] = a[i]%x; for(int i=1; i<=n; ++i) sum += b+n+1-lower_bound(b+1, b+n+1, x-b[i]); } lans -= sum*9; cout<<lans<<"\n"; return 0; }