douxiangshi6568 2014-04-04 10:06
浏览 72
已采纳

生成单个淘汰赛

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.

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.

eg (with 59 players) 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 !

  • 写回答

2条回答 默认 最新

  • dre26973 2014-04-04 10:11
    关注

    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.

    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. )


    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).

    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. )

    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...

    • 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 - P/2 => P/2

    • ... and from now you just go with the direct schedule of 2^N players (as P/2, as well as P, is the power of 2).
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?