UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#193870#3398. countwzj3330010020ms2384kbC++113.3kb2023-10-14 16:55:452023-10-14 18:38:46

answer

/**
 * @created     : 14.10.2023 16:41:19
 * @handle      : wzj33300
 */

#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
// #define int long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define rep1n(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define each(x, a) for (auto& x : a)
#define ar array
#define vec vector
#define range(i, n) rep(i, n)
using ll = long long;
using ull = unsigned long long;
using ld = double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pair<int, int> >;
using vvi = vector<vi>;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
}
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
}
#ifdef DEBUG
#include <algo/debug.h>
#else
#define debug(...) 42
#endif
// mod should be <2^31
const int mod = 1e9 + 7;
struct modint {
    int n;
    modint() : n(0) { ; }
    modint(ll m) {
        if (m < 0 || mod <= m) {
            m %= mod;
            if (m < 0) m += mod;
        }
        n = m;
    }
    operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
bool operator<(modint a, modint b) { return a.n < b.n; }
modint operator+=(modint& a, modint b) {
    a.n += b.n;
    if (a.n >= mod) a.n -= (int)mod;
    return a;
}
modint operator-=(modint& a, modint b) {
    a.n -= b.n;
    if (a.n < 0) a.n += (int)mod;
    return a;
}
modint operator*=(modint& a, modint b) {
    a.n = ((ll)a.n * b.n) % mod;
    return a;
}
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
    if (n == 0) return modint(1);
    modint res = (a * a) ^ (n / 2);
    if (n % 2) res = res * a;
    return res;
}

ll inv(ll a, ll p) { return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p); }
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) {
    a = a / b;
    return a;
}
typedef modint Mint;
ll qpow(ll x, ll n, ll m = mod) {
    if (n < 0) {
        ll res = qpow(x, -n, m);
        return qpow(res, m - 2, m);
    }
    if (abs(x) >= m) x %= m;
    if (x < 0) x += m;
    ll res = 1;
    while (n) {
        if (n & 1) res = res * x % m;
        x = x * x % m;
        n >>= 1;
    }
    return res;
}
// signed main() {
int main() {
    // freopen(".in", "r",stdin);
    // freopen(".out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vl a(n);
    vi c(n);
    vi b(25);
    rep(i, n) {
        cin >> a[i];
        ll x = a[i];
        int w = 0;
        while (x != 0) {
            x /= 10;
            w++;
        }
        b[c[i] = w]++;
    }
    Mint ans = 0;
    Mint y = 0;
    rep(i, 18) { y += b[i] * qpow(10, i); }
    rep(i, n) {
        ans += (n - 1) * a[i];
        ans += (y - (Mint)qpow(10, c[i])) * (Mint)a[i];
    }
    cout << ans << endl;
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 20
Accepted
time: 0ms
memory: 1272kb

input:

1000
332109541 265698305 339007233 386487277 65597920 217218907 436378017 221884663 270433433 268014...

output:

675688319

result:

ok single line: '675688319'

Test #2:

score: 20
Accepted
time: 0ms
memory: 1276kb

input:

1000
108652253 396843081 18739163 168730297 41598432 22132831 155692945 617160601 164753707 86147692...

output:

653845876

result:

ok single line: '653845876'

Test #3:

score: 20
Accepted
time: 0ms
memory: 1276kb

input:

1000
71158753 11073019 119630785 162780801 25368543 517705 123835636 254874371 4127795 157084999 201...

output:

126629477

result:

ok single line: '126629477'

Test #4:

score: 20
Accepted
time: 0ms
memory: 1276kb

input:

1000
496106605 30223789 139619196 52432001 12405522 405765988 35664524 102798391 192246625 760951562...

output:

891456070

result:

ok single line: '891456070'

Test #5:

score: 20
Accepted
time: 20ms
memory: 2384kb

input:

100000
227552529 170886571 513851125 46675201 188079376 255537313 266819605 69661658 214521435 33384...

output:

677195751

result:

ok single line: '677195751'