結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー chineristACchineristAC
提出日時 2021-07-30 20:37:01
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 85,680 KB
最終ジャッジ日時 2023-10-14 02:51:54
合計ジャッジ時間 3,839 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
83,500 KB
testcase_01 AC 129 ms
83,772 KB
testcase_02 AC 131 ms
83,508 KB
testcase_03 AC 128 ms
83,512 KB
testcase_04 AC 132 ms
84,752 KB
testcase_05 AC 130 ms
83,936 KB
testcase_06 AC 132 ms
84,040 KB
testcase_07 AC 140 ms
84,716 KB
testcase_08 AC 137 ms
84,280 KB
testcase_09 AC 136 ms
84,844 KB
testcase_10 AC 136 ms
84,688 KB
testcase_11 AC 135 ms
84,260 KB
testcase_12 AC 137 ms
84,464 KB
testcase_13 AC 139 ms
84,556 KB
testcase_14 AC 139 ms
84,280 KB
testcase_15 AC 140 ms
84,712 KB
testcase_16 AC 142 ms
84,916 KB
testcase_17 AC 145 ms
85,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import gcd,log

input = lambda :sys.stdin.buffer.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return (g1[n] * g2[r] % mod) * g2[n-r] % mod

mod = 10**9 + 7
N = 2*10**5
g1 = [1]*(N+1)
g2 = [1]*(N+1)
inverse = [1]*(N+1)

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

N = int(input())
c = [0] + li()

pow_10 = [1 for i in range(N)]
for i in range(1,N):
    pow_10[i] = 10 * pow_10[i-1] % mod

res = 0
for i in range(1,10):
    if c[i]==0:
        continue
    tmp = g1[N-1]
    for j in range(1,10):
        if j!=i:
            tmp *= g2[c[j]]
        else:
            tmp *= g2[c[j]-1]
        tmp %= mod
    for d in range(N):
        res += i * pow_10[d] * tmp
        res %= mod


print(res)
0