生成一个单淘汰赛 [英] Generate a single elimination tournament

查看:199
本文介绍了生成一个单淘汰赛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,很抱歉,我的英语,我会尽我所能来解释我的问题!

first , sorry for my english I'll do my best to explain my problem !

所以,我想产生一个单淘汰赛与无限数量的球员。

So , i'm trying to generate a single elimination tournament with an unlimited number of players.

现在我只是在想这件事,我什么都没有在纸面上,我想我不会有问题的比赛有两个电源(2 4 8 16 32的球员。),我的大脑挂在球员直接进入到第二轮,我不知道如何确定这个号码在哪里放置它们。

for now i'm just thinking about it , i have nothing on paper , i think i will not have problem for tournament with power of two ( 2 4 8 16 32 players..) , my brain hangs on players going directly to round 2 , i don't know how to determine this number and where to place them.

如(59玩家)

eg (with 59 players)

我觉得有一个公式,但我找不到它,我有一些想法,但我想得特别的情况下,不知道是否会工作的另一回事。

I think there is a formula but I can't find it, I have some ideas but i think too specifically on a case, without knowing if it would work for another .

感谢你,如果你能帮助我!

Thank you if you can help me !

推荐答案

对于给定的数N,发现它和2的最小功率至少大N. 59之间的区别,那将是5( 64 - 59)。这些5名球员将被添加到赛程的第二轮。

For a given number N, find the difference between it and the smallest power of 2 at least as large as N. For 59, that'll be 5 (64 - 59). Those 5 players will be added to the tournament schedule at the second round.

该算法允许所有玩家成为游戏的一部分,第二轮开始的时候 - 也就是,尽可能早地。它的解释很简单:想象一下,原本有2 ** N的球员 - 但有些只是没有来到他们的比赛,所以他们的对手走得更远束手就擒。 )

This algorithm allows for all the players to be part of the game when the second round begins - i.e., as early as possible. Its explanation is very simple: imagine that originally there were 2**N players - but some just didn't come to their games, so their opponents went further without a fight. )

一点题外话,你的公式应该考虑到,那就是应该从第二轮,而不是最弱的人进入游戏最强的选手。 )

As a sidenote, your formula should take into account that it's strongest players that should enter the game from the second round, not the weakest ones. )

第一步显然是计算的播放机将参加在第一轮的数量。现在,让我们继续认为缺少球员的隐喻 - 假设有64名选手原本,所以第一轮应该有32场比赛。但5播放器(64 - 59)没有来为那些游戏 - 这样的真实游戏的数目是27(64/2 - 5),和在第一轮的实参与者的数目是54(27 * 2)。

The first step apparently is calculating the number of players that will participate in the first round. Now, let's continue that 'missing players' metaphor - let's say there were 64 players originally, so the first round should have 32 games played. But 5 players (64 - 59) didn't come for those games - so the number of real games is 27 ( 64/2 - 5 ), and the number of real participants of the first round is 54 (27 * 2).

在第一轮结束后,就会有27人留在了比赛 - 这些人将与其他5人来参加,所以第二轮的球员总人数为32,其余是微不足道的,我想。 )

After the first round, there'll be 27 people left in the tournament - those people will be joined by those other 5 guys, so the total number of the 2nd round players is 32. The rest is trivial, I suppose. )

其实,这是很容易commonize。比方说,我们有 N 的球员,和2,至少大的最小功率 N P 。现在...

Actually, this is easy to commonize. Let's say we have N players, and the smallest power of 2 at least as large as N is P. Now...

  • 在第一轮应该有(N - (P - N))(或只是(2 * N - P))的球员。
  • 在第一轮比赛的总人数为(N - P / 2)。
  • 显然,同样是球员进入第二轮的数量。
  • 这些将被加盟(P - N)玩家留下没有发挥在第一轮, 所以玩家在第二轮总人数将...
  • The first round should have (N - (P - N)) (or just (2*N - P)) players.
  • The total number of the games in the first round is (N - P/2).
  • Apparently, the same is the number of players going into the 2nd round.
  • These will be joined by (P - N) players left without a play in the 1st round, so the total number of players in the 2nd round will be...

N - P / 2 + P - N =>对 - P / 2 => P / 2

  • ...从现在开始,你只去了2 ^ N球员直接时间表(如P / 2,以及磷,是2的幂)。

这篇关于生成一个单淘汰赛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆