Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
98227 | CSYZxiaojinyu | 早凉的函数2 | C++ | 解答错误 | 60 | 880 MS | 1816 KB | 805 | 2023-08-14 12:35:22 |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; long long a[MAXN]; long long f(long long x) { long long sum = 0; while (x) { sum += x % 10; x /= 10; } return sum; } int main() { int n; cin >> n; long long maxx = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; maxx = max(maxx, a[i]); } if (n <= 5000) { long long sum = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { long long x = a[i] + a[j]; sum += f(x); } } cout << sum; } else { long long sum1 = 0, ans = 0; for (int i = 0; i < n; ++i) { sum1 += f(a[i]); } for (int i = 0; i < n; ++i) { ans += n * f(a[i]) + sum1; } cout << ans; } return 0; }