結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー c-yanc-yan
提出日時 2021-07-31 09:00:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 15,924 KB
最終ジャッジ日時 2023-10-14 14:32:27
合計ジャッジ時間 1,726 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,792 KB
testcase_01 AC 15 ms
7,804 KB
testcase_02 AC 14 ms
7,856 KB
testcase_03 AC 14 ms
7,872 KB
testcase_04 AC 55 ms
11,256 KB
testcase_05 AC 25 ms
8,880 KB
testcase_06 AC 27 ms
9,060 KB
testcase_07 AC 70 ms
12,840 KB
testcase_08 AC 55 ms
11,516 KB
testcase_09 AC 64 ms
12,068 KB
testcase_10 AC 56 ms
11,576 KB
testcase_11 AC 42 ms
10,488 KB
testcase_12 AC 58 ms
11,668 KB
testcase_13 AC 63 ms
12,116 KB
testcase_14 AC 45 ms
10,664 KB
testcase_15 AC 63 ms
12,192 KB
testcase_16 AC 63 ms
11,960 KB
testcase_17 AC 107 ms
15,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

m = 1000000007

N, *c = map(int, open(0).read().split())

fac = [1] * (N + 1)
for i in range(N):
    fac[i + 1] = fac[i] * (i + 1)
    fac[i + 1] %= m

x = fac[N - 1] * (pow(10, N, m) - 1) * pow(9, -1, m) % m
frac = 0
denom = 1
for i in range(9):
    if c[i] == 0:
        continue
    frac += c[i] * (i + 1) * x
    frac %= m
    denom *= pow(fac[c[i]], -1, m)
    denom %= m
print(frac * denom % m)
0