結果

問題 No.573 a^2[i] = a[i]
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-08-10 02:59:39
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 847 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 86,612 KB
実行使用メモリ 79,344 KB
最終ジャッジ日時 2023-07-28 11:50:47
合計ジャッジ時間 6,363 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,232 KB
testcase_01 AC 71 ms
71,016 KB
testcase_02 AC 72 ms
70,864 KB
testcase_03 AC 74 ms
71,052 KB
testcase_04 AC 71 ms
71,232 KB
testcase_05 AC 72 ms
71,200 KB
testcase_06 AC 72 ms
71,208 KB
testcase_07 AC 73 ms
71,008 KB
testcase_08 AC 72 ms
71,224 KB
testcase_09 AC 73 ms
71,092 KB
testcase_10 AC 75 ms
70,868 KB
testcase_11 AC 73 ms
71,200 KB
testcase_12 AC 73 ms
71,292 KB
testcase_13 AC 72 ms
70,868 KB
testcase_14 AC 71 ms
71,360 KB
testcase_15 AC 72 ms
71,228 KB
testcase_16 AC 72 ms
71,292 KB
testcase_17 AC 73 ms
71,240 KB
testcase_18 AC 73 ms
71,020 KB
testcase_19 AC 71 ms
71,048 KB
testcase_20 AC 72 ms
71,076 KB
testcase_21 AC 74 ms
71,092 KB
testcase_22 AC 73 ms
71,236 KB
testcase_23 AC 74 ms
71,196 KB
testcase_24 AC 72 ms
71,096 KB
testcase_25 AC 74 ms
71,012 KB
testcase_26 AC 73 ms
70,996 KB
testcase_27 AC 75 ms
71,196 KB
testcase_28 AC 71 ms
71,196 KB
testcase_29 AC 73 ms
71,076 KB
testcase_30 AC 74 ms
71,208 KB
testcase_31 AC 73 ms
71,136 KB
testcase_32 AC 73 ms
71,204 KB
testcase_33 AC 76 ms
71,244 KB
testcase_34 AC 76 ms
71,020 KB
testcase_35 AC 75 ms
71,292 KB
testcase_36 AC 75 ms
71,224 KB
testcase_37 AC 74 ms
71,088 KB
testcase_38 AC 75 ms
71,296 KB
testcase_39 AC 81 ms
76,180 KB
testcase_40 AC 82 ms
76,112 KB
testcase_41 AC 82 ms
76,228 KB
testcase_42 AC 81 ms
76,124 KB
testcase_43 AC 84 ms
76,320 KB
testcase_44 AC 86 ms
76,164 KB
testcase_45 AC 87 ms
76,412 KB
testcase_46 AC 139 ms
79,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
mod = 10 ** 9 + 7


class Combi():
    def __init__(self, N, mod):
        self.power = [1 for _ in range(N+1)]
        self.rev = [1 for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.power[i] = (self.power[i-1]*i) % self.mod
        self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.rev[j-1] = (self.rev[j]*j) % self.mod

    def C(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod

    def P(self, K, R):
        if K < R:
            return 0
        else:
            return (self.power[K])*(self.rev[K-R]) % self.mod


res = 0
c = Combi(N, mod)
for i in range(1, N+1):
    res += c.C(N, i)*pow(i, N-i, mod)
    res %= mod
print(res)
0