結果
| 問題 |
No.1629 Sorting Integers (SUM of M)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-30 21:19:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 683 bytes |
| コンパイル時間 | 568 ms |
| コンパイル使用メモリ | 67,160 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 22:38:54 |
| 合計ジャッジ時間 | 1,228 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 |
ソースコード
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 60,mod=1e9+7;
typedef long long LL;
int cnt[N];
LL qpow(LL x,LL k){
LL res=1;
while(k){
if(k&1)res=res*x%mod;
x=x*x%mod;
k>>=1;
}
return res;
}
int main(){
int n;
scanf("%d",&n);
for(int i=1;i<=9;i++){
scanf("%d",&cnt[i]);
}
LL t=1;
LL c=1,res=0;
for(int i=1;i<=n;i++){
t=t*i%mod;
res=(res+c)%mod;
c=c*10%mod;
}
LL ans=0;
for(int i=1;i<=9;i++){
LL z=1;
for(int j=1;j<=cnt[i];j++){
z=z*j%mod;
}
t=t*qpow(z,mod-2)%mod;
}
for(int i=1;i<=9;i++){
if(cnt[i]){
ans=(ans+t*cnt[i]%mod*i%mod*qpow(n,mod-2)%mod*res%mod)%mod;
}
}
cout<<ans;
return 0;
}