結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー yudai1102jpyudai1102jp
提出日時 2021-07-30 22:38:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 37,944 KB
最終ジャッジ日時 2023-10-14 06:16:48
合計ジャッジ時間 2,470 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,900 KB
testcase_01 AC 17 ms
7,696 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 17 ms
7,792 KB
testcase_04 AC 90 ms
20,548 KB
testcase_05 AC 34 ms
11,044 KB
testcase_06 AC 39 ms
11,800 KB
testcase_07 AC 123 ms
25,988 KB
testcase_08 AC 94 ms
21,348 KB
testcase_09 AC 109 ms
23,520 KB
testcase_10 AC 96 ms
21,608 KB
testcase_11 AC 68 ms
16,912 KB
testcase_12 AC 97 ms
21,996 KB
testcase_13 AC 105 ms
23,712 KB
testcase_14 AC 78 ms
18,256 KB
testcase_15 AC 111 ms
24,116 KB
testcase_16 AC 108 ms
23,612 KB
testcase_17 AC 190 ms
37,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)  # 再帰関数使う時有効

N = int(input())
c = list(map(int, input().split()))

MOD = 10**9+7


def bikkuri(n):
    if n == 1 or n == 0:
        return 1
    return (n*bikkuri(n-1)) % MOD


a = bikkuri(N-1)
b = 1

s = 0
for i in range(9):
    if c[i] != 0:
        b *= bikkuri(c[i])
        b %= MOD
        # one = one*10+1
        s += (i+1)*c[i]

n = (a*pow(b, -1, MOD)) % MOD
n *= s
ans = 0
for i in range(N):
    ans = ans*10+n
    ans %= MOD
print(ans)
0