結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー ryuusagiryuusagi
提出日時 2021-07-30 21:14:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 117,912 KB
最終ジャッジ日時 2023-10-14 02:49:04
合計ジャッジ時間 3,857 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,376 KB
testcase_01 AC 72 ms
71,364 KB
testcase_02 AC 74 ms
71,344 KB
testcase_03 AC 75 ms
71,076 KB
testcase_04 AC 116 ms
91,220 KB
testcase_05 AC 93 ms
77,660 KB
testcase_06 AC 94 ms
78,764 KB
testcase_07 AC 162 ms
100,208 KB
testcase_08 AC 140 ms
93,364 KB
testcase_09 AC 163 ms
96,660 KB
testcase_10 AC 136 ms
94,472 KB
testcase_11 AC 125 ms
87,968 KB
testcase_12 AC 176 ms
94,424 KB
testcase_13 AC 184 ms
97,320 KB
testcase_14 AC 150 ms
89,664 KB
testcase_15 AC 187 ms
99,820 KB
testcase_16 AC 184 ms
97,440 KB
testcase_17 AC 272 ms
117,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, *c = map(int, open(0).read().split())
a = 1
ans = 0

mod = 10 ** 9 + 7
fact = [1, 1]
finv = [1, 1]
inv = [0, 1]
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((inv[mod % i] * (mod - mod // i)) % mod)
    finv.append((finv[-1] * inv[-1]) % mod)

for _ in range(n):
    for i in range(9):
        if c[i]:
            b = fact[n-1]
            for j in range(9):
                b *= finv[c[j] - (i == j)]
                b %= mod
            ans += (i + 1) * a * b
            ans %= mod
    a *= 10
    a %= mod
print(ans)
0