Tap here to switch tabs
Problem
Submissions

Problem: Count of Matches in Tournament

Try to solve the Count of Matches in Tournament problem.

Statement

You are given an integer n, representing the initial number of teams participating in a tournament.

The tournament proceeds according to the following rules:

  • If the current count of teams is even, each team is paired with another team. A total of n/2n / 2 matches are played, and n/2n / 2 teams advance to the next round.

  • If the current count of teams is odd, one team randomly advances, and the remaining teams are paired. A total of (n−1)/2(n - 1) / 2 matches are played, and (n−1)/2+1(n - 1) / 2 + 1 teams advance to the next round.

Return the total count of matches played throughout the tournament until a single winner is determined.

Constraints:

  • 1≤n≤2001 \le n \le 200

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count of Matches in Tournament

Try to solve the Count of Matches in Tournament problem.

Statement

You are given an integer n, representing the initial number of teams participating in a tournament.

The tournament proceeds according to the following rules:

  • If the current count of teams is even, each team is paired with another team. A total of n/2n / 2 matches are played, and n/2n / 2 teams advance to the next round.

  • If the current count of teams is odd, one team randomly advances, and the remaining teams are paired. A total of (n−1)/2(n - 1) / 2 matches are played, and (n−1)/2+1(n - 1) / 2 + 1 teams advance to the next round.

Return the total count of matches played throughout the tournament until a single winner is determined.

Constraints:

  • 1≤n≤2001 \le n \le 200