多项式集
我在解决这个问题时遇到问题,它类似于组合非唯一字母集,但略有不同。
令k、m和n为正整数。我们有 nm 个球、m 个颜色、n 个球和 k 个独特标记的箱子。有多少种不同的方法来选择n个球放入k个袋子中?
例如,如果 m = 3、n = k = 2,则结果为 21。有 3 种颜色,我们从总共 6 个球中选择 2 个球放入 2 个箱子中。
(-,WW),(-,WR),(-,WB)...
(WW,-),(WR,-)...
(宽,宽),(宽,右)...
(B,W),(B,R) ...
这个问题的正常版本不需要选择总元素的子集。该问题产生 n! /x
校正(清晰度)->你总共有 nm 个球。每种颜色有 n 个球,其中有 m 种颜色;然后,从这里随机选择总共 nm 个球中的 n 个,并将它们放入 k 个不同的箱子中。
I'm having a problem figuring out this problem, it is similar to combining sets of non-unique letters, but is slightly different.
Let k, m, and n be positive integers. We have nm balls, m colors, n balls, and k uniquely labeled bins. How many different ways are there to select n balls to put into the k bags?
For example, if m = 3, n = k = 2, the result is 21. There are 3 colors where we are choosing 2 balls out of the total 6 to place into 2 bins.
(-, WW), (-,WR), (-, WB) ...
(WW, -), (WR, -) ...
(W,W), (W,R) ...
(B,W), (B,R) ...
The normal version of this problem does not require the selection of a subset of the total elements. That problem yields n! / x1! x2! x3! ... where x1, x2, x3 are groups of duplicated letters.
correction (clarity) -> you have a total of nm balls. n balls of each color where there are m colors; from here you then choose n of these total nm balls randomly and place them into the k distinct bins.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让我确定我的问题是正确的。我们有
m
种颜色。我们有k
个垃圾箱。我们想要选择 n 个球并将它们放入箱子中。我们有足够的每种颜色的球,我们不必担心任何特定颜色的球用完。在这种情况下,问题归结为我们有多少种
n
个m*k
种球。 (一种由颜色和容器决定。)有一个标准技巧来计算它。首先让我们对种类进行编号。放下所有第一种球。然后是分隔器。然后是所有第二种球。然后是分隔器。依此类推,直到我们拥有所有n
个球和k*m - 1
分隔线。这个过程是完全可逆的,如果我们将n + k*m - 1
个东西排成一行,选择其中的n
个作为球,其余的作为分隔物,我们然后可以给球着色并将它们放入箱子中,以在k
个箱子中获得n
个m
种颜色的球。因此答案是
选择(n + k*m - 1, n)
。(请注意,这是我在知道答案后得出的推理。我的实际答案路径更长且更迂回。)
Let me be sure I have the question right. We have
m
colors. We havek
bins. We want to selectn
balls and place them in the bins. We have enough balls of each color that we don't have to worry about running out of any particular color.In that case, the problem boils down to how many ways we have have
n
balls ofm*k
kinds. (A kind being determined by color and bin.) There is a standard trick to calculate this. First let's number the kinds. Put down all of the balls of the first kind. Then a divider. Then all the balls of the second kind. Then a divider. And so on until we have alln
balls andk*m - 1
dividers down. This procedure is completely reversible, if we taken + k*m - 1
things in a row, selectn
of them to be balls and the rest to be dividers, we can then color the balls and put them into bins to get ton
balls ofm
colors ink
bins.Therefore the answer is
choose(n + k*m - 1, n)
.(Note, this is the reasoning that I came up with after I knew the answer. My actual path to the answer was much longer and more circuitous.)
我相信你可以把这个问题看成m个独立的n-多重组合。
所以答案是 m * multichoose(n, k),其中 multichoose(a, b) = C(a + b -1, b)。
编辑:这假设您询问每种颜色的 n 个球并放置所有 nm 个球。
I believe that you can treat this problem as m independent n-multicombinations.
So the answer is m * multichoose(n, k), where multichoose(a, b) = C(a + b -1, b).
Edit: This assumes you are asking about n balls of each color and placing all nm balls.