Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
98255 | CSYZLinZR | 早凉的函数2 | C++ | 解答错误 | 0 | 37 MS | 1820 KB | 1184 | 2023-08-14 13:19:37 |
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; typedef long long i64; const i64 SIZE = 5e5+5; int n, m; i64 a[SIZE]; int f(i64 x) { int ret = 0; while (x) { ret += x % 10; x /= 10; } return ret; } namespace o3 { using :: n; using :: m; using :: a; int main() { sort(a + 1, a + 1 + n); int sum = 0, ans = 0; for (int i = 1; i <= n; ++i) sum += a[i]; for (int i = 1; i <= n; ++i) { int k = lower_bound(a + 1, a + 1 + n, 10 - a[i]) - a; ans += n - k + 1; ans += a[i] * n + sum - 10 * (n - k + 1); } cout << ans << endl; return 0; } } int main() { #ifdef fio freopen("../test.in","r",stdin); #endif cin >> n; bool fgb = true, fga = true; for (int i = 1; i <= n; ++i) { scanf("%lld",a+i); if (a[i] > 9) fga = false; i64 cp = a[i]; while (cp) { if (cp % 10 > 4) fgb = false; cp /= 10; } } if (n == 1) { printf("%d\n",f(a[1])); } else if (fgb) { int sum = 0; for (int i = 1; i <= n; ++i) { sum += f(a[i]); } printf("%d\n",2 * n * sum); } else if (fga) { return o3::main(); } else { puts("1"); } return 0; }