結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー ryusukeryusuke
提出日時 2022-01-26 21:00:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 77,428 KB
最終ジャッジ日時 2023-08-25 03:23:13
合計ジャッジ時間 3,104 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,220 KB
testcase_01 AC 74 ms
71,448 KB
testcase_02 AC 68 ms
71,304 KB
testcase_03 AC 69 ms
71,452 KB
testcase_04 AC 73 ms
76,820 KB
testcase_05 AC 73 ms
76,004 KB
testcase_06 AC 72 ms
76,332 KB
testcase_07 AC 74 ms
76,924 KB
testcase_08 AC 73 ms
76,680 KB
testcase_09 AC 72 ms
76,816 KB
testcase_10 AC 72 ms
76,720 KB
testcase_11 AC 72 ms
76,556 KB
testcase_12 AC 72 ms
76,852 KB
testcase_13 AC 74 ms
76,820 KB
testcase_14 AC 72 ms
76,536 KB
testcase_15 AC 72 ms
76,984 KB
testcase_16 AC 75 ms
76,612 KB
testcase_17 AC 75 ms
77,428 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