結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー chocoruskchocorusk
提出日時 2021-07-30 20:41:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,227 bytes
コンパイル時間 3,455 ms
コンパイル使用メモリ 187,028 KB
実行使用メモリ 19,244 KB
最終ジャッジ日時 2023-10-14 02:55:59
合計ジャッジ時間 4,613 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
19,044 KB
testcase_01 AC 7 ms
19,012 KB
testcase_02 AC 8 ms
19,036 KB
testcase_03 AC 7 ms
19,008 KB
testcase_04 AC 8 ms
19,016 KB
testcase_05 AC 8 ms
19,016 KB
testcase_06 AC 8 ms
18,964 KB
testcase_07 AC 9 ms
19,012 KB
testcase_08 AC 9 ms
19,008 KB
testcase_09 AC 9 ms
19,020 KB
testcase_10 AC 9 ms
19,240 KB
testcase_11 AC 9 ms
19,020 KB
testcase_12 AC 9 ms
19,012 KB
testcase_13 AC 8 ms
19,244 KB
testcase_14 AC 8 ms
19,120 KB
testcase_15 AC 9 ms
19,080 KB
testcase_16 AC 9 ms
18,960 KB
testcase_17 AC 9 ms
19,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
mint f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int main()
{
	int n; cin>>n;
	fac(n);
	int c[10];
	for(int i=1; i<=9; i++){
		cin>>c[i];
	}
	mint x=(mint(10).pow(n)-1)/9;
	mint ans=0;
	for(int i=1; i<=9; i++){
		mint v=f[n-1];
		for(int j=1; j<=9; j++){
			if(i==j) v*=invf[c[j]-1];
			else v*=invf[c[j]];
		}
		ans+=v*i*x;
	}
	cout<<ans.val()<<endl;

    return 0;
}
0