You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

p01.py 271B

5 years ago
123456789101112131415
  1. import sys
  2. text = sys.stdin.read()
  3. ns = [int(s) for s in text.splitlines()]
  4. def handle(n):
  5. m = n // 3 - 2
  6. return [m] + handle(m) if m > 0 else []
  7. if __name__ == '__main__':
  8. print(sum(handle(n)[0] for n in ns))
  9. print(sum(sum(handle(n)) for n in ns))