結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー asaringoasaringo
提出日時 2021-07-30 22:17:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 1,066 bytes
コンパイル時間 1,514 ms
コンパイル使用メモリ 165,928 KB
実行使用メモリ 6,616 KB
最終ジャッジ日時 2023-10-14 05:21:16
合計ジャッジ時間 4,206 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
6,524 KB
testcase_01 AC 38 ms
6,532 KB
testcase_02 AC 38 ms
6,532 KB
testcase_03 AC 38 ms
6,568 KB
testcase_04 AC 49 ms
6,524 KB
testcase_05 AC 41 ms
6,512 KB
testcase_06 AC 40 ms
6,484 KB
testcase_07 AC 103 ms
6,508 KB
testcase_08 AC 74 ms
6,500 KB
testcase_09 AC 108 ms
6,512 KB
testcase_10 AC 75 ms
6,484 KB
testcase_11 AC 69 ms
6,464 KB
testcase_12 AC 151 ms
6,616 KB
testcase_13 AC 164 ms
6,468 KB
testcase_14 AC 120 ms
6,516 KB
testcase_15 AC 168 ms
6,484 KB
testcase_16 AC 164 ms
6,464 KB
testcase_17 AC 290 ms
6,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef pair<int,int> P ;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define chmin(a,b) a = min(a,b) ;

const int mod = 1000000007 ;

ll n , k ;
vector<int> digit ;

ll fac[202020] ;
ll inv[202020] ;
ll C[10] ;

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

void init(){
    fac[0] = fac[1] = 1 ;
    rrep(i,2,202020) fac[i] = fac[i-1] * i % mod ;
    inv[0] = inv[1] = 1 ;
    rrep(i,2,202020) inv[i] = inv[i-1] * powmod(i,mod-2) % mod ;
}

int main(){
    init() ;
    cin >> n ;
    rep(i,9) cin >> C[i] ;
    ll res = 0 ;
    rep(i,n){
        rep(j,9){
            if(C[j] == 0) continue ;
            ll val = fac[n-1] * inv[C[j] - 1] % mod * (j + 1) % mod * powmod(10,i) % mod ;
            rep(k,9) if(j != k) (val *= inv[C[k]]) %= mod ;
            (res += val) %= mod ;
        }
    }
    cout << res << endl ;
}
0