結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー ゆきのんゆきのん
提出日時 2021-07-30 20:42:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 1,970 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 203,460 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2023-10-14 02:58:29
合計ジャッジ時間 4,053 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,784 KB
testcase_01 AC 7 ms
6,428 KB
testcase_02 AC 7 ms
6,428 KB
testcase_03 AC 8 ms
6,428 KB
testcase_04 AC 39 ms
6,464 KB
testcase_05 AC 20 ms
6,560 KB
testcase_06 AC 22 ms
6,688 KB
testcase_07 AC 92 ms
6,696 KB
testcase_08 AC 72 ms
6,404 KB
testcase_09 AC 87 ms
6,404 KB
testcase_10 AC 63 ms
6,544 KB
testcase_11 AC 52 ms
6,664 KB
testcase_12 AC 87 ms
6,660 KB
testcase_13 AC 97 ms
6,616 KB
testcase_14 AC 67 ms
6,460 KB
testcase_15 AC 98 ms
6,532 KB
testcase_16 AC 95 ms
6,432 KB
testcase_17 AC 168 ms
6,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace atcoder;
//using namespace boost::multiprecision;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll mod=1e9 + 7;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={0,1,0,-1,0,1,-1,1,-1};
int dy[]={0,0,1,0,-1,1,-1,-1,1};


int M_N = 200000;

vector<ll> fact;
vector<ll> inver(M_N+1);
 
ll combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
ll fpow(ll a, ll n){
    ll x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    ll s=1;
    fact.push_back(1);
    for(int i=1;i<=M_N;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[M_N]=fpow(fact[M_N],mod-2);
    for(int i=M_N-1;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}
 


int main(){
    set_combi();
    int n;cin >> n;
    vector<int> c(10, 0);
    for (int i = 0; i < 9; i++) {
        cin >> c[i + 1];
    }
    ll t = 1;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            ll p = 1;
            ll s = n - 1;
            for (int k = 0; k < 10; k++) {
                if(k == j) continue;
                p = p * combi(s, c[k]) %mod;
                s -= c[k];
            }
            ans = (ans + t * p %mod * j)%mod;
        }
        t = t * 10 % mod;
    }
    cout << ans << endl;
    return 0;
}
0