結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-07-30 21:25:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,155 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 79,868 KB
最終ジャッジ日時 2023-10-14 03:19:58
合計ジャッジ時間 8,299 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,164 KB
testcase_01 AC 72 ms
71,024 KB
testcase_02 AC 75 ms
71,144 KB
testcase_03 AC 75 ms
71,348 KB
testcase_04 AC 185 ms
77,596 KB
testcase_05 AC 103 ms
76,288 KB
testcase_06 AC 109 ms
76,180 KB
testcase_07 AC 406 ms
78,476 KB
testcase_08 AC 275 ms
77,868 KB
testcase_09 AC 412 ms
78,064 KB
testcase_10 AC 283 ms
77,864 KB
testcase_11 AC 239 ms
77,548 KB
testcase_12 AC 567 ms
78,188 KB
testcase_13 AC 621 ms
78,056 KB
testcase_14 AC 433 ms
77,808 KB
testcase_15 AC 646 ms
78,212 KB
testcase_16 AC 628 ms
78,212 KB
testcase_17 AC 1,155 ms
79,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
import math
n = int(input())
c = list(map(int,input().split()))

fac_arr = [1] * (n+1)
r_s_fac_arr = [1] * (n+1)
mod = 10 ** 9 + 7
for i in range(1,n+1):
    fac_arr[i] = (fac_arr[i-1] % mod) * i % mod
    r_s_fac_arr[i] = (r_s_fac_arr[i-1] % mod) * pow(i,mod-2,mod) % mod 
ans = 0
nn = fac_arr[n]
for i in range(9):
    if c[i] != 0:
        nn = nn * r_s_fac_arr[c[i]] % mod
ans = 0
nn = nn * pow(n,mod-2,mod) % mod
for i in range(9):
    if c[i] != 0:
        for j in range(n):
            ans = (ans  + (i+1) * nn *  c[i] * pow(10,j,mod)) % mod 
print(ans)
    
0