[DP]bzoj1037 - cool's Blog

[DP]bzoj1037

cool posted @ 2015年10月07日 15:55 in DP , 330 阅读

BZOJ传送门

话说我的DP真的好水 这种题目根本做不出

f[i][j][x][y] 表示 总共i人 有j个男的 从i人往前的一段人中,男比女最多多x人 女比男最多做y人

这是 网上的题解 代码如下

	f[0][0][0][0] = 1;
	for (int i = 0;i < n+m;i++)
		for (int j = 0;j <= n;j++)
			for (int x = 0;x <= k;x++)
				for (int y = 0;y <= k;y++)
					if (f[i][j][x][y])
					{
						if (x + 1 <= k&&j+1 <= n)
							f[i+1][j+1][x+1][max(y-1,0)] += f[i][j][x][y],f[i+1][j+1][x+1][max(y-1,0)] %= mod;
						if (y + 1 <= k&&i+1-j <= m)
							f[i+1][j][max(x-1,0)][y+1] += f[i][j][x][y],f[i+1][j][max(x-1,0)][y+1] %= mod;
					}

但有点让我想不通 为什么不干脆f[i][j][x][y] i表示男 j表示女呢 而且空间 时间都快了。

而且在bz上也AC了 请大神教导

NCERT Mathematics Sa 说:
2022年9月16日 22:32

Mathematics is one of the subjects which plays a key role in everyone’s life and it’s very important to each student. NCERT Mathematics Sample Paper Class 2 Mathematics is not a certain time helping subject, it is along with the people for their whole life at any time and at anywhere. It should begin from the foundation of Education to enable 2nd students to understand mathematics easily. Downloading NCERT Mathematics Sample Paper 2023 Class 2 for all formats of exams conducted under Term-1, Term-2 and other types of exams has available for every candidate who wants to get a keen clarity on the question pattern of the exam paper along with revised important questions.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee