douxiangshi6568 2014-04-04 02: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 02: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条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 宝塔面板一键迁移使用不了
  • ¥15 求一个按键录像存储到内存卡的ESP32CAM代码
  • ¥15 如何单独修改下列canvas推箱子代码target参数?,插入图片代替其形状,就是哪个绿色的圆圈每关用插入的图片替代
  • ¥20 四叉树的创建和输出问题
  • ¥15 javaweb连接数据库,jsp文件加载不出来
  • ¥15 matlab关于高斯赛德尔迭代的应用编撰。(相关搜索:matlab代码|迭代法)
  • ¥15 损失匹配问题,求解答
  • ¥15 3500常用汉字书法体检测数据集下载
  • ¥15 odoo17在制造模块或采购模块良品与次品如何分流和在质检模块下如何开发
  • ¥15 Qt音乐播放器的音乐文件相对路径怎么写
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部