結果
| 問題 |
No.1629 Sorting Integers (SUM of M)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-30 20:52:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 915 bytes |
| コンパイル時間 | 1,934 ms |
| コンパイル使用メモリ | 169,736 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 22:43:00 |
| 合計ジャッジ時間 | 2,268 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 6 WA * 8 |
ソースコード
#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;
}