628A - Теннисный турнир
The problem suggested by unprost.
Here you can simply model the process. Or you can note that after each match some player drops out. In total n - 1 players will drop out. So the first answer is (n - 1) * (2b + 1). Obviously the second answer is np.
Complexity: O(log2n), O(logn) or O(1) depends on the realization.