Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
98415 | CSYZChenQX | 早凉的函数2 | C++ | 解答错误 | 40 | 1000 MS | 41524 KB | 1334 | 2023-08-14 18:28:34 |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MX = 2e5 + 5; int n; ll a[MX], f[MX]; ll lans = 0, num, sum, r; ll ten[17] = {0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 10000000000000000}; ll s[16*MX]; int c[16*MX]; int haha[18]; 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(int j=1; j<=16; j++) { s[++num] = a[i]%ten[j]; if(s[num]==s[num-1]) num--; if(a[i]<=ten[j]) break; } } sort(s+1, s+num+1); haha[16] = num+1; for(int i=1; i<=15; i++) haha[i] = lower_bound(s+haha[i-1], s+num+1, ten[i])-s; for(int i=1; i<=n; i++) { for(int j=1; j<=16; j++) { int p = lower_bound(s+1, s+num+1, ten[j]-a[i]%ten[j])-s; if(haha[j]<=p) continue; c[p] ++; c[haha[j]] --; } } for(int i=1; i<=num; i++) c[i] += c[i-1], sum += c[i]; lans -= sum*9; cout<<lans<<"\n"; return 0; }