nq1s788

27 B

Jun 5th, 2025
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 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 y < 4:
  8.         cl[0].append((x, y))
  9.     elif x > 5:
  10.         cl[1].append((x, y))
  11.     else:
  12.         cl[2].append((x, y))
  13. cent = []
  14. for i in range(3):
  15.     best_rst = 1000000000000000000000000
  16.     best_c = 0
  17.     for c in cl[i]:
  18.         rst = 0
  19.         for e in cl[i]:
  20.             rst += dist(c, e)
  21.         if rst < best_rst:
  22.             best_rst = rst
  23.             best_c = c
  24.     cent.append(best_c)
  25. print(int(((cent[0][0] + cent[1][0] + cent[2][0]) / 3) * 10000), int(((cent[0][1] + cent[1][1] + cent[2][1]) / 3) * 10000))
Advertisement
Add Comment
Please, Sign In to add comment