結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー carrot46carrot46
提出日時 2021-07-30 20:36:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 1,914 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 205,180 KB
実行使用メモリ 7,816 KB
最終ジャッジ日時 2023-10-14 02:51:22
合計ジャッジ時間 3,094 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,720 KB
testcase_01 AC 9 ms
7,628 KB
testcase_02 AC 10 ms
7,632 KB
testcase_03 AC 10 ms
7,712 KB
testcase_04 AC 10 ms
7,708 KB
testcase_05 AC 10 ms
7,572 KB
testcase_06 AC 10 ms
7,708 KB
testcase_07 AC 10 ms
7,684 KB
testcase_08 AC 10 ms
7,740 KB
testcase_09 AC 10 ms
7,680 KB
testcase_10 AC 10 ms
7,816 KB
testcase_11 AC 10 ms
7,556 KB
testcase_12 AC 10 ms
7,736 KB
testcase_13 AC 10 ms
7,552 KB
testcase_14 AC 10 ms
7,712 KB
testcase_15 AC 10 ms
7,688 KB
testcase_16 AC 10 ms
7,712 KB
testcase_17 AC 10 ms
7,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
//#pragma GCC optimize("Ofast")
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
using tp = tuple<ll, ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

using mint = modint1000000007;
using vm = vector<mint>;

const ll MAX_N = ll(4e+5) + 10;
vm fact(MAX_N, mint(1)), fact_inv(MAX_N, mint(1)), n_inv(MAX_N, mint(1));
void makefact(){
    mint tmp;
    reps(i,2,MAX_N) fact[i] = fact[i-1] * mint::raw(i);
    fact_inv[MAX_N - 1] = fact[MAX_N - 1].inv();
    Rreps(i, MAX_N - 1, 1){
        fact_inv[i] = fact_inv[i + 1] * mint::raw(i + 1);
        n_inv[i + 1] = fact[i] * fact_inv[i + 1];
    }
}
mint nCm(ll n, ll m){
    return fact[n] * fact_inv[n-m] * fact_inv[m];
}
mint nCm_inv(ll n, ll m){
    return fact[n-m] * fact[m] * fact_inv[n];
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    makefact();
    cin>>N;
    vec c(10, 0);
    rep(i, 9) cin>>c[i+1];
    mint res(0), tmp(0), ten(1);
    rep(i, N){
        tmp += ten;
        ten *= 10;
    }
    tmp *= fact[N-1];
    rep(i, 10) tmp *= fact_inv[c[i]];
    rep(i, 10) res += tmp * c[i] * i;
    cout<<res.val()<<endl;
}
0