結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー FromBooskaFromBooska
提出日時 2023-04-09 15:07:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 898 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 89,344 KB
最終ジャッジ日時 2024-04-15 05:13:33
合計ジャッジ時間 2,751 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,096 KB
testcase_01 AC 38 ms
51,840 KB
testcase_02 AC 40 ms
52,224 KB
testcase_03 AC 40 ms
51,712 KB
testcase_04 AC 118 ms
72,576 KB
testcase_05 AC 63 ms
62,336 KB
testcase_06 AC 66 ms
62,976 KB
testcase_07 AC 143 ms
78,336 KB
testcase_08 AC 116 ms
72,448 KB
testcase_09 AC 131 ms
74,368 KB
testcase_10 AC 120 ms
72,448 KB
testcase_11 AC 93 ms
68,608 KB
testcase_12 AC 120 ms
74,036 KB
testcase_13 AC 130 ms
74,240 KB
testcase_14 AC 101 ms
70,016 KB
testcase_15 AC 134 ms
76,032 KB
testcase_16 AC 129 ms
74,240 KB
testcase_17 AC 211 ms
89,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# TLEした、もっとうまい式があるということだろう
# https://qiita.com/ryusuke920/items/41c266243fc4c4d5327f
# https://yukicoder.me/problems/no/1629/editorial

N = int(input())
C = [0] + list(map(int, input().split()))
mod = 10**9+7

base1 = (pow(10, N, mod)-1)*pow(9, mod-2, mod)

# nCrメモ化パッケージ
factorial = [1] #0分
inverse = [1] #0分
for i in range(1, N+1):
    factorial.append(factorial[-1]*i%mod)
    inverse.append(pow(factorial[-1], mod-2, mod))

def nCr_fast(N, R, MOD):
    if N < R or R < 0:
        return 0
    elif R == 0 or R == N:
        return 1
    return factorial[N]*inverse[R]*inverse[N-R]%MOD

base2 = factorial[N-1]
temp = 1
for i in range(1, 10):
    temp *= factorial[C[i]]
    temp %= mod
base3 = pow(temp, mod-2, mod)
base4 = 0
for i in range(1, 10):
    base4 += i*C[i]
    base4 %= mod

ans = (base1*base2*base3*base4)%mod
print(ans)
0