結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー pepper_aobutapepper_aobuta
提出日時 2021-07-30 20:48:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,419 bytes
コンパイル時間 1,495 ms
コンパイル使用メモリ 165,392 KB
実行使用メモリ 9,584 KB
最終ジャッジ日時 2023-10-14 03:05:38
合計ジャッジ時間 2,503 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int c[10];
    for(int i = 1 ; i < 10 ; i++)cin >> c[i];
    
    ll mod = 1000000007;
    
    ll fact[n + 1];
    ll fact_inv[n + 1];
    ll inv[n + 1];
    
    fact[0] = 1;
    fact[1] = 1;
    fact_inv[0] = 1;
    fact_inv[1] = 1;
    inv[1] = 1;
    
    for(int i = 2 ; i <= n ; i++){
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
    
    ll keisuu[10];
    
    for(int i = 1 ; i < 10 ; i++){
        if(c[i] == 0){
            keisuu[i] = 0;
            continue;
        }
        keisuu[i] = fact[n - 1];
        
        for(int j = 1 ; j <= 9 ; j++){
            if(j == i){
                keisuu[i] *= fact_inv[c[i] - 1];
                keisuu[i] %= mod;
            }
            if(j != i){
                keisuu[i] *= fact_inv[c[j]];
                keisuu[i] %= mod;
            }
        }
    }
    
    ll keisuu_sum = 0;
    for(int i = 1 ; i < 10 ; i++)keisuu_sum += keisuu[i];
    
    ll ten[n + 1];
    ten[0] = 1;
    
    ll ans = 1;
    
    for(int i = 1 ; i < n ; i++){
        ten[i] = ten[i - 1] * 10;
        ten[i] %= mod;
        ans += ten[i];
        ans %= mod;
    }
    
    ans *= keisuu_sum;
    ans %= mod;
    
    cout << ans << endl;
    return 0;
}
0