結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー Tawara
提出日時 2016-07-14 21:28:26
言語 Python2
(2.7.18)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 6,784 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-10-15 20:04:17
合計ジャッジ時間 3,742 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

R = xrange
def solve():
	p = 10**9+7
	Comb = [[0]*76 for i in R(76)]
	Comb[0][0] = 1
	cx = [0]*5; cy = [0]*5; cN = [0]*5; use = [0]*5
	Gx,Gy,K = map(int,raw_input().split())
	for i in R(K):
		cx[i],cy[i],cN[i] = map(int,raw_input().split())
	for i in R(K*15):
		for j in R(i+2):
			Comb[i+1][j] = (Comb[i][j] + (Comb[i][j-1] if j > 0 else 0)) % p
	ans = 0
	x0 = y0 = 0
	for i in R(cN[0]+1):
		use[0] = i
		x0 = cx[0]*i
		y0 = cy[0]*i
		for j in R(cN[1]+1):
			use[1] = j
			x1 = x0 + cx[1]*j
			y1 = y0 + cy[1]*j
			for k in R(cN[2]+1):
				use[2] = k
				x2 = x1 + cx[2]*k
				y2 = y1 + cy[2]*k
				for l in R(cN[3]+1):
					use[3] = l
					x3 = x2 + cx[3]*l
					y3 = y2 + cy[3]*l
					for m in R(cN[4]+1):
						use[4] = m
						x4 = x3 + cx[4]*m
						y4 = y3 + cy[4]*m
						if x4 != Gx or y4 != Gy:
							continue  
						total = sum(use)
						cnt = 1
						for n in xrange(5):
							cnt = cnt * Comb[total][use[n]] % p
							total -= use[n]
						ans = (ans + cnt) % p
	print ans
solve()
0