Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
98425 | CSYZChenQX | 早凉的函数2 | C++ | 解答错误 | 40 | 963 MS | 41468 KB | 1300 | 2023-08-14 21:04:33 |
#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[16] = {0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000}; ll s[15*MX]; int c[15*MX]; int haha[17]; 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<=15; 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[15] = num+1; haha[0] = 1; for(int i=1; i<=14; 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<=15; j++) { int p = lower_bound(s+haha[j-1], s+haha[j], ten[j]-a[i]%ten[j])-s; 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; }