結果
| 問題 |
No.1629 Sorting Integers (SUM of M)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-02 10:15:58 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 1,141 bytes |
| コンパイル時間 | 3,205 ms |
| コンパイル使用メモリ | 248,700 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-02 10:16:03 |
| 合計ジャッジ時間 | 4,435 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i)
#define all(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;
ll modpow(ll a, ll n, ll m) {
ll res = 1;
while (n > 0) {
if (n & 1) res = res * a % m;
a = a * a % m;
n >>= 1;
}
return res;
}
ll modinv(ll a, ll m) {
return modpow(a, m - 2, m);
}
int main() {
cin.tie(nullptr);
ll N;
cin >> N;
vector<ll> c(9);
rep(i, 0, 9) cin >> c[i];
vector<ll> frac(2e5 + 10);
frac[0] = 1;
rep(i, 1, 2e5 + 10) frac[i] = frac[i - 1] * i % mod;
ll ans = 0;
rep(i, 0, 9) {
if (c[i] == 0) continue;
ll tmp = frac[N - 1];
rep(j, 0, 9) {
if (i == j) tmp *= modinv(frac[c[j] - 1], mod);
else tmp *= modinv(frac[c[j]], mod);
tmp %= mod;
}
ans += (i + 1) * tmp % mod;
ans %= mod;
}
ans *= (modpow(10, N, mod) - 1 + mod) % mod;
ans %= mod;
ans *= modinv(9, mod);
ans %= mod;
cout << ans << '\n';
}