Advertisement
RareScrap

Untitled

Jun 16th, 2020
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. from math import sqrt
  2.  
  3. class Position:
  4.     x,y = 0,0
  5.  
  6.     def __init__(self, x, y):
  7.       self.x = x
  8.       self.y = y
  9.  
  10.  
  11. def inputPosition(pos):
  12.     pos.x = int(input('введите x'))
  13.     pos.y = int(input('введите y'))
  14.     return pos
  15.  
  16. def squared_distance(posA, posB):
  17.     dx = posA.x-posB.x
  18.     dy = posA.y-posB.y
  19.     return dx * dx + dy * dy
  20.  
  21.  
  22. i = open("input.txt", "r")
  23. o = open("output.txt", "w")
  24.  
  25. size = int(i.readline())
  26.  
  27. points = []#np.linspace()
  28. distances = set()
  29.  
  30. ii = 0
  31. while ii < size:
  32.     inputStr = i.readline().split()
  33.  
  34.     t1 = Position(inputStr[0], 0) if len(inputStr) == 1 else Position(inputStr[0], inputStr[1])
  35.  
  36.     points.append(t1)
  37.     ii = ii + 1
  38.  
  39. a,b = 0,0
  40. while a in points:
  41.     while b in points:
  42.         squared_d = squared_distance(a, b)
  43.         if (squared_d != 0): distances.insert(squared_d)
  44.  
  45. o.write(str(len(distances)) + '\n')
  46.  
  47. distance = 0
  48. while distance in distances:
  49.     o.write(sqrt(distance) + '\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement