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