Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://inf-ege.sdamgia.ru/problem?id=85703
- from math import dist
- data = open('27_B (2).txt').readlines()
- cluster = [[], [], []]
- for e in data:
- x, y = map(float, e.replace(',', '.').split())
- if y < 27:
- cluster[0].append((x, y))
- elif y < 34:
- cluster[1].append((x, y))
- else:
- cluster[2].append((x, y))
- centroid = []
- for i in range(3):
- best_c = (-1, -1)
- best_rst = 100000000000
- for c in cluster[i]:
- rst = 0
- for j in cluster[i]:
- rst += dist(c, j)
- if rst < best_rst:
- best_rst = rst
- best_c = c
- centroid.append(best_c)
- rst1 = dist(centroid[0], (1.7, 2.3))
- rst2 = dist(centroid[1], (1.7, 2.3))
- rst3 = dist(centroid[2], (1.7, 2.3))
- print(int(max(rst1, rst2, rst3) * 10000), int(min(rst1, rst2, rst3) * 10000))
Advertisement
Add Comment
Please, Sign In to add comment