結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー KKT89KKT89
提出日時 2021-08-03 06:50:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,090 bytes
コンパイル時間 2,933 ms
コンパイル使用メモリ 214,648 KB
実行使用メモリ 4,628 KB
最終ジャッジ日時 2023-10-14 21:05:25
合計ジャッジ時間 3,710 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 3 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 3 ms
4,352 KB
testcase_07 AC 3 ms
4,352 KB
testcase_08 AC 3 ms
4,352 KB
testcase_09 AC 3 ms
4,352 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 3 ms
4,356 KB
testcase_13 AC 3 ms
4,352 KB
testcase_14 AC 3 ms
4,352 KB
testcase_15 AC 3 ms
4,352 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 5 ms
4,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

constexpr ll mod=1e9+7;

void add(ll &x,ll y){
    x+=y;
    if(x>=mod)x-=mod;
}

ll mod_pow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> c(9);
    for(int i=0;i<9;i++){
        cin >> c[i];
    }
    ll pow=0;
    ll cur=1;
    for(int i=0;i<n;i++){
        add(pow,cur);
        cur*=10;
        cur%=mod;
    }
    vector<ll> fac(n+1);
    fac[0]=1;
    for(ll i=1;i<=n;i++){
        fac[i]=fac[i-1]*(ll)i%mod;
    }
    ll res=pow*fac[n-1]%mod;
    ll ad=0;
    for(int i=0;i<9;i++){
        res*=mod_pow(fac[c[i]],mod-2);
        res%=mod;
        ad+=(ll)(i+1)*c[i];
    }
    cout << res*ad%mod << endl;
}
0