Advertisement
Guest User

4.1

a guest
Dec 13th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. from math import sqrt
  2.  
  3.  
  4. def get_argument(value1, value2):
  5.     return (value1 - value2) ** 2
  6.  
  7.  
  8. def get_s(x1, y1, x2, y2):
  9.     return sqrt(get_argument(y1, y2) + get_argument(x1, x2)) * centersDistance
  10.  
  11.  
  12. def get_shadow(q, s):
  13.     return (lightHeight / (lightHeight - d * q)) * s - s
  14.  
  15.  
  16. def check_line(x1, y1, x2, y2):
  17.     if (lightX - x1) * (y2 - y1) == (x2 - x1) * (lightY - y1):
  18.         return True
  19.     return False
  20.  
  21.  
  22. lightHeight = 50
  23. d = 4
  24. lightX = 4
  25. lightY = 4
  26. centersDistance = 5
  27.  
  28. res = 0
  29. inputData = []
  30. n = int(input())
  31. for i in range(0, n):
  32.     itemData = eval(input())
  33.     inputData.append(itemData)
  34.  
  35. for item in inputData:
  36.     itemX = item[0]
  37.     itemY = item[1]
  38.     itemS = get_s(lightX, lightY, itemX, itemY) + d / 2
  39.     itemShadow = get_shadow(item[2], itemS)
  40.     for potential in inputData:
  41.         if item != potential:
  42.             pX = potential[0]
  43.             pY = potential[1]
  44.             if check_line(itemX, itemY, pX, pY):
  45.                 pS = get_s(lightX, lightY, pX, pY) + d / 2
  46.                 if itemS < pS:
  47.                     if itemShadow > get_s(itemX, itemY, pX, pY) - d:
  48.                         res += 1
  49.  
  50. print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement