結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー 👑 H20H20
提出日時 2021-07-30 22:16:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 2,222 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 117,096 KB
最終ジャッジ日時 2023-10-14 05:18:16
合計ジャッジ時間 3,467 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
116,364 KB
testcase_01 AC 114 ms
116,712 KB
testcase_02 AC 113 ms
116,568 KB
testcase_03 AC 113 ms
116,428 KB
testcase_04 AC 122 ms
116,748 KB
testcase_05 AC 120 ms
116,720 KB
testcase_06 AC 118 ms
116,692 KB
testcase_07 AC 119 ms
117,032 KB
testcase_08 AC 120 ms
117,032 KB
testcase_09 AC 120 ms
116,652 KB
testcase_10 AC 120 ms
116,660 KB
testcase_11 AC 119 ms
116,656 KB
testcase_12 AC 119 ms
116,752 KB
testcase_13 AC 121 ms
116,752 KB
testcase_14 AC 123 ms
116,868 KB
testcase_15 AC 120 ms
116,984 KB
testcase_16 AC 117 ms
116,756 KB
testcase_17 AC 129 ms
117,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# ModInt 参考は以下のサイト
# https://qiita.com/wotsushi/items/c936838df992b706084c

MOD = 10**9+7
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )




N = int(input())
A = list(map(int, input().split())) 
L = [1]
mod = MOD
for i in range(3*10**5):
    L.append(L[-1]*10%mod)

fact = [1]
for n in range(1,3*10**5):
    fact.append(fact[-1]*n%MOD)

temp = ModInt(fact[N])
for i in range(9):
    temp = temp / ModInt(fact[A[i]])
su = ModInt(0)
for i in range(9):
    su = su + (i+1) * temp * ModInt(A[i]) / ModInt(N)

ans = 0
for i in range(N):
    ans = ans + L[i]*su
print(ans) 
0