結果
問題 | No.1629 Sorting Integers (SUM of M) |
ユーザー | chocorusk |
提出日時 | 2021-07-30 20:41:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 1,227 bytes |
コンパイル時間 | 2,890 ms |
コンパイル使用メモリ | 182,192 KB |
最終ジャッジ日時 | 2025-01-23 10:28:08 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 |
ソースコード
#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; }