結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-07-30 22:00:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 857 bytes
コンパイル時間 2,902 ms
コンパイル使用メモリ 86,792 KB
実行使用メモリ 118,280 KB
最終ジャッジ日時 2023-10-14 04:44:24
合計ジャッジ時間 4,497 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,224 KB
testcase_01 AC 69 ms
71,228 KB
testcase_02 AC 67 ms
71,140 KB
testcase_03 AC 69 ms
71,108 KB
testcase_04 AC 129 ms
90,876 KB
testcase_05 AC 91 ms
77,276 KB
testcase_06 AC 92 ms
78,420 KB
testcase_07 AC 184 ms
98,600 KB
testcase_08 AC 151 ms
93,104 KB
testcase_09 AC 190 ms
95,548 KB
testcase_10 AC 158 ms
93,084 KB
testcase_11 AC 142 ms
87,192 KB
testcase_12 AC 225 ms
93,188 KB
testcase_13 AC 235 ms
95,912 KB
testcase_14 AC 184 ms
88,884 KB
testcase_15 AC 242 ms
98,028 KB
testcase_16 AC 242 ms
95,872 KB
testcase_17 AC 373 ms
118,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
C = list(map(int,input().split()))
mod = 10**9+7

fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]%mod*finv[n-r]%mod

ans = 0
ten = 1
for i in range(1,n+1):
    for j,c in enumerate(C,1):
        if c == 0:
            continue
        can = 1
        all = n-1
        for k in range(9):
            if k == j-1:
                can *= nCr(all,C[k]-1,mod)
                can %= mod
                all -= C[k]-1
            else:
                can *= nCr(all,C[k],mod)
                can %= mod
                all -= C[k]
        ans += ten*can*j
        ans %= mod


    ten *= 10
    ten %= mod
print(ans)
0