当前位置:网站首页>Daily question 1688 Number of matches in the competition

Daily question 1688 Number of matches in the competition

2022-07-05 05:41:00 A big pigeon

topic : The game has n A team , Eliminate half of each round , If n Is odd , So many teams are directly promoted .

Find the total number of games .

Explain :( simulation )

class Solution:
    def numberOfMatches(self, n: int) -> int:
        res = 0
        while n > 1:
            res += n//2
            n = (n+1) // 2
        return res 

原网站

版权声明
本文为[A big pigeon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140620422616.html