結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー ryusukeryusuke
提出日時 2022-01-26 21:04:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 15,940 KB
最終ジャッジ日時 2023-08-25 03:32:11
合計ジャッジ時間 2,241 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,728 KB
testcase_01 AC 15 ms
7,764 KB
testcase_02 AC 15 ms
7,820 KB
testcase_03 AC 15 ms
7,796 KB
testcase_04 AC 54 ms
11,132 KB
testcase_05 AC 25 ms
8,708 KB
testcase_06 AC 28 ms
9,032 KB
testcase_07 AC 70 ms
12,652 KB
testcase_08 AC 58 ms
11,496 KB
testcase_09 AC 64 ms
12,172 KB
testcase_10 AC 58 ms
11,668 KB
testcase_11 AC 42 ms
10,412 KB
testcase_12 AC 58 ms
11,740 KB
testcase_13 AC 65 ms
11,936 KB
testcase_14 AC 47 ms
10,688 KB
testcase_15 AC 66 ms
12,152 KB
testcase_16 AC 65 ms
12,244 KB
testcase_17 AC 107 ms
15,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
c = list(map(int, input().split()))

mod = 10 ** 9 + 7

# 階乗テーブル
fac = [1] * (n + 1)
for i in range(n):
    fac[i + 1] = fac[i] * (i + 1) 
    fac[i + 1] %= mod

# 10^kの和
t = (pow(10, n, mod) - 1) * pow(9, -1, mod)

# i * Ci の和
i_Ci = 0
for i in range(9):
    i_Ci += (i + 1) * c[i]

# 1 / (c1! * c2! * ... * c9!) の積
fac_Ci = 1
for i in range(9):
    if fac[c[i]] == 0: continue
    fac_Ci *= pow(fac[c[i]], -1, mod)

ans = t * i_Ci * fac_Ci * fac[n - 1] % mod

print(ans)
0