結果
問題 | No.1629 Sorting Integers (SUM of M) |
ユーザー |
|
提出日時 | 2021-07-30 20:55:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 948 bytes |
コンパイル時間 | 1,573 ms |
コンパイル使用メモリ | 169,636 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 22:46:15 |
合計ジャッジ時間 | 2,294 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 |
ソースコード
#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) {if (c[i] == 0) continue;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;}