Skip to content

Instantly share code, notes, and snippets.

@ZeronSix
Last active November 5, 2015 10:58
Show Gist options
  • Save ZeronSix/15bf7888cf6cd529d5e1 to your computer and use it in GitHub Desktop.
Save ZeronSix/15bf7888cf6cd529d5e1 to your computer and use it in GitHub Desktop.
11.5. Режем торт
import math
angles = []
n_top = 0
with open("tests/01") as fi:
n = int(fi.readline())
for _ in range(n):
x, y = [int(s) for s in fi.readline().split()]
angle = math.degrees(math.atan2(y, x))
if angle < 0:
angles.append((180 + angle, True))
else:
angles.append((angle, False))
n_top += 1
angles.sort()
i = 0
while n_top != n // 2:
print(angles[i][1])
if angles[i][1]:
n_top += 1
else:
n_top -= 1
i += 1
if i > 0:
angle = (angles[i - 1][0] + angles[i][0]) / 2
else:
angle = angles[i][0] / 2
with open("output.txt", "w") as fo:
fo.write(str(angle))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment