fork download
  1. class Solution(object):
  2. def totalMoney(self, n):
  3. """
  4. :type n: int
  5. :rtype: int
  6. """
  7. m = 0
  8. total = 0
  9. if n <= 7:
  10. print("from 1")
  11. return (n*(n+1)) // 2
  12.  
  13. else:
  14. for i in range(n // 7):
  15. num = 7 + m
  16. total += ((num * (num + 1)) / 2) - ((m*(m+1)) // 2)
  17. m += 1
  18. print(i, total, m)
  19.  
  20.  
  21. if (n % 7 > 0):
  22. res = (n % 7) + m
  23. total += ((res * (res+ 1)) / 2) - ((m*(m+1)) // 2)
  24.  
  25. return int(total)
  26.  
  27.  
Success #stdin #stdout 0.08s 14076KB
stdin
Standard input is empty
stdout
Standard output is empty