Advertisement
nq1s788

27 A

Jun 5th, 2025
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #7581 https://kpolyakov.spb.ru/school/ege/gen.php?action=viewAllEgeNo&egeId=27&cat183=on
  2. from math import dist
  3. data = open('27.txt').readlines()
  4. cl = [[], []]
  5. for e in data:
  6.     x, y = map(float, e.replace(',', '.').split())
  7.     if x < 1:
  8.         cl[0].append((x, y))
  9.     else:
  10.         cl[1].append((x, y))
  11. cent = []
  12. for i in range(2):
  13.     best_rst = 1000000000000
  14.     best_c = 0
  15.     for c in cl[i]:
  16.         rst = 0
  17.         for e in cl[i]:
  18.             rst += dist(c, e)
  19.         if rst < best_rst:
  20.             best_rst = rst
  21.             best_c = c
  22.     cent.append(best_c)
  23. print(int(((cent[0][0] + cent[1][0]) / 2) * 10000), int(((cent[0][1] + cent[1][1]) / 2) * 10000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement