Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
98153 wzj33300 早凉的函数2 C++ 通过 100 366 MS 3400 KB 784 2023-08-14 12:23:54

Tests(50/50):


#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]; ll 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 << endl; return 0; }


测评信息: