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.

22 lines
540B

  1. import re
  2. text = open(0).read()
  3. x1, x2, y1, y2 = [int(n) for n in re.findall(r'-?\d+', text)]
  4. peaks = []
  5. for vyi in range(-100, 100):
  6. for vxi in range(0, 400):
  7. x, y, vx, vy = 0, 0, vxi, vyi
  8. for _ in range(200):
  9. x += vx
  10. y += vy
  11. vx -= vx // abs(vx) if vx else 0
  12. vy -= 1
  13. if x1 <= x <= x2 and y1 <= y <= y2:
  14. peaks.append(vyi * (vyi + 1) // 2)
  15. break
  16. if x > x2:
  17. break
  18. print(max(peaks))
  19. print(len(peaks))