fork download
  1. # your code goes here
  2. class Solution(object):
  3. def numberOfMatches(self, n):
  4. """
  5. :type n: int
  6. :rtype: int
  7. """
  8. matchs = 0
  9. while n != 1:
  10. if n % 2 == 0:
  11. matchs += (n//2) # 6
  12. n //= 2 # 2
  13.  
  14. else:
  15. matchs += ((n-1)//2) # 3
  16. n = (n // 2) + 1 # 4
  17.  
  18. return matchs
Success #stdin #stdout 0.13s 14108KB
stdin
Standard input is empty
stdout
Standard output is empty