結果

問題 No.1035 Color Box
ユーザー 双六双六
提出日時 2020-08-02 19:10:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 941 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 79,796 KB
最終ジャッジ日時 2023-09-26 10:42:09
合計ジャッジ時間 7,281 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
79,564 KB
testcase_01 AC 94 ms
71,372 KB
testcase_02 AC 91 ms
71,372 KB
testcase_03 AC 106 ms
77,452 KB
testcase_04 AC 109 ms
77,536 KB
testcase_05 AC 104 ms
77,416 KB
testcase_06 AC 93 ms
71,556 KB
testcase_07 AC 96 ms
71,520 KB
testcase_08 AC 158 ms
79,344 KB
testcase_09 AC 130 ms
78,056 KB
testcase_10 AC 96 ms
71,916 KB
testcase_11 AC 92 ms
71,236 KB
testcase_12 AC 93 ms
71,600 KB
testcase_13 AC 144 ms
78,816 KB
testcase_14 AC 153 ms
79,264 KB
testcase_15 AC 163 ms
79,560 KB
testcase_16 AC 94 ms
71,680 KB
testcase_17 AC 92 ms
71,420 KB
testcase_18 AC 92 ms
71,236 KB
testcase_19 AC 162 ms
79,796 KB
testcase_20 AC 95 ms
71,516 KB
testcase_21 AC 94 ms
71,540 KB
testcase_22 AC 94 ms
71,488 KB
testcase_23 AC 95 ms
71,568 KB
testcase_24 AC 94 ms
71,520 KB
testcase_25 AC 95 ms
71,560 KB
testcase_26 AC 94 ms
71,524 KB
testcase_27 AC 93 ms
71,520 KB
testcase_28 AC 93 ms
71,520 KB
testcase_29 AC 94 ms
71,376 KB
testcase_30 AC 93 ms
71,372 KB
testcase_31 AC 97 ms
71,432 KB
testcase_32 AC 94 ms
71,576 KB
testcase_33 AC 95 ms
71,620 KB
testcase_34 AC 94 ms
71,536 KB
testcase_35 AC 94 ms
71,516 KB
testcase_36 AC 94 ms
71,576 KB
testcase_37 AC 95 ms
71,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

class Combination(object):
	def __init__(self, N, con):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1

		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % con
			self.inv[i] = self.inv[con % i] * (con - (con // i)) % con
			self.finv[i] = self.finv[i - 1] * self.inv[i] % con

	def com(self, N, k):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % con

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	C = Combination(M, con)
	ans = 0
	for i in range(M + 1):
		ans += (-1) ** (M - i) * C.com(M, i) * pow(i, N, con)
		ans %= con

	print(ans)

if __name__ == '__main__':
	main()
0