什么是分组计划,使每两个人组合在一起,只有一次?组合、计划、个人

由网友(欲黄大帝i)分享简介:因此​​,我们有N多人。 So, we have N people. 我们每天做N / 2组脱离出来,也就是说,2人在一组。Everyday, we make N/2 groups out of them, i.e., 2 people are in one group.我们保持每天分组,直到每两个人已经配对只...

因此​​,我们有N多人。

So, we have N people.

我们每天做N / 2组脱离出来,也就是说,2人在一组。

Everyday, we make N/2 groups out of them, i.e., 2 people are in one group.

我们保持每天分组,直到每两个人已经配对只有一次,不多不少。

We keep grouping everyday, until every two people have been paired exactly once, no more no less.

请给每天的分组计划。

下面是我的想法:

n个的人,还有 N *(N-1)/ 2 可能对。因为每天我们会有 N / 2 对,完全我们需要 N-1 天。

Out of N people, there are N * (N-1) / 2 possible pairs. Since everyday we will have N/2 pairs, totally we will need N-1 days.

因此​​,基本上,如果我们的算法需要N多人作为输入的名单,我们将输出 N-1 列表,每个列表将包含对了一天。

So basically, if our algorithm takes a list of N people as input, we will output N-1 lists, each list will contain the pairs for a day.

但如何组织这些 N *(N-1)/ 2 对转换成 N-1 天?

But how to organise these N * (N-1) / 2 pairs into N-1 days?

我知道该怎么做,在一个暴力破解的方式,像最坏的情况下,我们尝试对每一个组合的每一天,甚至更好地利用hashtset看到了一天的组合是否可能不是(HashSet的一天)。

I know how to do it in a bruteforce way, like worst case, we try every combinations of pairs for every day, or better use hashtset to see whether a combination for a day is possible or not (a hashset for a day).

不过,我认为必须有一个更优雅,更有效的方式来解决这个问题。图?

But I think there must be a more elegant and efficient way to solve the problem. Graph?

推荐答案

看一看 http://en.wikipedia.org/wiki/Round-robin_tournament#Scheduling_algorithm - 这似乎是回答你的问题。我也看到在国际象棋比赛和债券定居点的背景下,这个讨论。

Have a look at http://en.wikipedia.org/wiki/Round-robin_tournament#Scheduling_algorithm - This seems to answer your question. I have also seen this discussed in the context of chess matches and bond settlements.

阅读全文

相关推荐

最新文章