結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー lloyzlloyz
提出日時 2021-12-26 18:09:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 619 ms
コンパイル使用メモリ 81,556 KB
実行使用メモリ 64,216 KB
最終ジャッジ日時 2023-10-24 13:08:14
合計ジャッジ時間 1,676 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,416 KB
testcase_01 AC 34 ms
53,416 KB
testcase_02 AC 34 ms
53,416 KB
testcase_03 AC 34 ms
53,416 KB
testcase_04 AC 43 ms
61,480 KB
testcase_05 AC 41 ms
59,988 KB
testcase_06 AC 45 ms
60,116 KB
testcase_07 AC 46 ms
62,320 KB
testcase_08 AC 43 ms
61,600 KB
testcase_09 AC 45 ms
61,972 KB
testcase_10 AC 44 ms
61,660 KB
testcase_11 AC 42 ms
60,940 KB
testcase_12 AC 44 ms
61,720 KB
testcase_13 AC 45 ms
61,972 KB
testcase_14 AC 43 ms
61,144 KB
testcase_15 AC 45 ms
62,044 KB
testcase_16 AC 45 ms
61,972 KB
testcase_17 AC 50 ms
64,216 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