結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー lloyzlloyz
提出日時 2021-12-26 16:25:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 686 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 64,764 KB
最終ジャッジ日時 2023-10-24 10:55:03
合計ジャッジ時間 3,236 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,556 KB
testcase_01 AC 37 ms
53,556 KB
testcase_02 AC 37 ms
53,556 KB
testcase_03 AC 37 ms
53,556 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fact = [1] * (n + 1)
inv = [1] * (n + 1)
finv = [1] * (n + 1)
for i in range(2, 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

sum_num = 0
for i in range(9):
    if A[i] == 0:
        continue
    res = fact[n - A[i]]
    for j in range(9):
        if i == j:
            continue
        if A[j] == 0:
            continue
        res *= finv[A[j]]
        res %= mod
    sum_num += (i + 1) * res * A[i] % mod
    sum_num %= mod
ans = 0
for i in range(n):
    ans += sum_num * pow(10, i, mod) % mod
    ans %= mod
print(ans)
0