結果

問題 No.1629 Sorting Integers (SUM of M)
コンテスト
ユーザー ktr216
提出日時 2021-07-30 20:52:19
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 915 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,595 ms
コンパイル使用メモリ 183,764 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-05 02:28:28
合計ジャッジ時間 1,741 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 6 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> c(9);
    rep(i, 0, 9) cin >> c[i];
    vector<ll> f(N + 1, 1);
    ll ans = 0, b = 0, MOD = 1e9 + 7;
    rep(i, 0, N) {
        b = (b * 10 + 1) % MOD;
        f[i + 1] = f[i] * (i + 1) % MOD;
    }
    rep(i, 0, 9) {
        ll d = f[N - 1];
        rep(j, 0, 9) {
            if (i == j) {
                d = d * mod_pow(f[c[j] - 1], MOD - 2, MOD) % MOD;
            } else {
                d = d * mod_pow(f[c[j]], MOD - 2, MOD) % MOD;
            }
        }
        ans += d * (i + 1) % MOD * b % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}
0