Tournament Byes

Easy · rating 1000 · Math

A single-elimination bracket needs a power-of-two number of entrants. Read n players and print how many byes (free passes) round one must hand out to reach the next power of two — 0 if n is already a power of two.

Constraints: 1 ≤ n ≤ 109

Related problems

Open Tournament Byes in Code Arena →