Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
98327 CSYZShenJY 早凉的函数2 C++ 通过 100 347 MS 3372 KB 955 2023-08-14 15:10:15

Tests(50/50):


#include <iostream> #include <algorithm> #define int long long using namespace std; const int N = 2e5 + 5; int n; int a[N], b[N]; int f(int x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } int read() { char ch = getchar(); int sum = 0; while (ch < '0' || ch > '9') { ch = getchar(); } while (ch >= '0' && ch <= '9') { sum = (sum << 1) + (sum << 3) + (ch ^ 48); ch = getchar(); } return sum; } signed main() { cin >> n; int ans = 0; for (int i = 1; i <= n; ++ i) { a[i] = read(); ans += f(a[i]); } ans *= 2 * n; int sum = 0; for (int i = 10; i <= 1e15; i *= 10) { for (int j = 1; j <= n; ++ j) { b[j] = a[j] % i; } sort(b + 1, b + n + 1); for (int j = 1; j <= n; ++ j){ sum += -(lower_bound(b + 1, b + n + 1, i - b[j]) - b - 1) + n; } } cout << ans - sum * 9; return 0; }


测评信息: