【发布时间】:2012-01-27 08:16:13
【问题描述】:
假设我们有以下树:
1
9
2
13
3
10
4
15
5
11
6
14
7
12
8
元素在哪里(匹配):
1-8是第1轮
9-12是第2轮
13-14是第3轮
15 是第 4 轮
如何确定树中元素“n”的轮次?
我目前的公式是:
total_rounds = floor(log(totalTeams,2));
matches_per_round = (totalTeams / pow(2, current_round))
next_match_id = (totalTeams/2) + ceil(match_id/2)
total_matches = total_teams - 1
【问题讨论】:
-
如果这是作业,请标记它。
标签: c++ algorithm algebra tournament