소스 검색

magic

master
Roderic Day 3 년 전
부모
커밋
76f4793b97
1개의 변경된 파일21개의 추가작업 그리고 0개의 파일을 삭제
  1. +21
    -0
      y2021/p17.py

+ 21
- 0
y2021/p17.py 파일 보기

@@ -0,0 +1,21 @@
import re


text = open(0).read()
x1, x2, y1, y2 = [int(n) for n in re.findall(r'-?\d+', text)]
peaks = []
for vyi in range(-100, 100):
for vxi in range(0, 400):
x, y, vx, vy = 0, 0, vxi, vyi
for _ in range(200):
x += vx
y += vy
vx -= vx // abs(vx) if vx else 0
vy -= 1
if x1 <= x <= x2 and y1 <= y <= y2:
peaks.append(vyi * (vyi + 1) // 2)
break
if x > x2:
break
print(max(peaks))
print(len(peaks))

Loading…
취소
저장