blob: dbb2a5740db8e83e428ed69888e0500c1030e9ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/usr/bin/python3
import sys
import heapq
import itertools
from collections import defaultdict, Counter, deque
# target area: x=96..125, y=-144..-98
# y(t) ~ -t^2 + DY*t
p2 = 0
ans = 0
for DX in range(150):
for DY in range(-150, 1000):
ok = False
max_y = 0
x = 0
y = 0
dx = DX
dy = DY
for t in range(1000):
x += dx
y += dy
max_y = max(max_y, y)
if dx > 0:
dx -= 1
elif dx < 0:
dx += 1
dy -= 1
# if 20<=x<=30 and -10<=y<=-5:
if 96 <= x <= 125 and -144 <= y <= -98:
ok = True
if ok:
p2 += 1
if max_y > ans:
ans = max_y
print(DX, DY, ans)
print(ans)
print(p2)
|