nq1s788

27 B

Apr 18th, 2026
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. #https://inf-ege.sdamgia.ru/problem?id=85703
  2. from math import dist
  3. data = open('27_B (2).txt').readlines()
  4. cluster = [[], [], []]
  5. for e in data:
  6.     x, y = map(float, e.replace(',', '.').split())
  7.     if y < 27:
  8.         cluster[0].append((x, y))
  9.     elif y < 34:
  10.         cluster[1].append((x, y))
  11.     else:
  12.         cluster[2].append((x, y))
  13. centroid = []
  14. for i in range(3):
  15.     best_c = (-1, -1)
  16.     best_rst = 100000000000
  17.     for c in cluster[i]:
  18.         rst = 0
  19.         for j in cluster[i]:
  20.             rst += dist(c, j)
  21.         if rst < best_rst:
  22.             best_rst = rst
  23.             best_c = c
  24.     centroid.append(best_c)
  25. rst1 = dist(centroid[0], (1.7, 2.3))
  26. rst2 = dist(centroid[1], (1.7, 2.3))
  27. rst3 = dist(centroid[2], (1.7, 2.3))
  28. print(int(max(rst1, rst2, rst3) * 10000), int(min(rst1, rst2, rst3) * 10000))
  29.  
Advertisement
Add Comment
Please, Sign In to add comment