結果

問題 No.834 Random Walk Trip
ユーザー 双六双六
提出日時 2020-07-16 00:47:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 968 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 101,088 KB
最終ジャッジ日時 2023-08-14 19:13:24
合計ジャッジ時間 5,429 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,720 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 88 ms
71,424 KB
testcase_05 AC 91 ms
71,600 KB
testcase_06 AC 91 ms
71,844 KB
testcase_07 AC 91 ms
71,864 KB
testcase_08 AC 89 ms
71,700 KB
testcase_09 AC 89 ms
71,404 KB
testcase_10 AC 92 ms
71,896 KB
testcase_11 AC 91 ms
71,716 KB
testcase_12 AC 90 ms
71,684 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 91 ms
71,408 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 116 ms
80,976 KB
testcase_19 AC 201 ms
100,388 KB
testcase_20 AC 111 ms
80,744 KB
testcase_21 WA -
testcase_22 AC 91 ms
71,584 KB
testcase_23 WA -
testcase_24 AC 100 ms
78,096 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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 main():
	N, M = getlist()
	Com = Combination(M, con)
	ans = 0
	for i in range(10 ** 6):
		x = M - N * i
		if x > 0:
			ans += Com.com(x, int(x // 2))
		else:
			break
	
	ans %= con
	print(ans)

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