結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー lloyzlloyz
提出日時 2021-12-26 18:09:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 33,380 KB
最終ジャッジ日時 2023-10-24 13:08:27
合計ジャッジ時間 2,709 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,084 KB
testcase_01 AC 28 ms
10,084 KB
testcase_02 AC 28 ms
10,084 KB
testcase_03 AC 27 ms
10,084 KB
testcase_04 AC 118 ms
19,652 KB
testcase_05 AC 49 ms
12,260 KB
testcase_06 AC 55 ms
12,824 KB
testcase_07 AC 168 ms
23,876 KB
testcase_08 AC 137 ms
20,444 KB
testcase_09 AC 148 ms
22,292 KB
testcase_10 AC 131 ms
20,708 KB
testcase_11 AC 93 ms
17,012 KB
testcase_12 AC 132 ms
20,972 KB
testcase_13 AC 143 ms
22,028 KB
testcase_14 AC 105 ms
18,068 KB
testcase_15 AC 142 ms
22,556 KB
testcase_16 AC 150 ms
22,292 KB
testcase_17 AC 247 ms
33,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

ans = sum([(i + 1) * A[i] for i in range(9)]) % mod
ans *= (pow(10, n, mod) - 1 + mod) * inv[9] % mod
ans %= mod
ans *= fact[n - 1]
ans %= mod
for i in range(9):
    ans *= finv[A[i]]
    ans %= mod
print(ans)

0