Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- from cmath import phase
- stevilo = int(input())
- class strelci():
- def __init__(self, x, y, r):
- self.x = x
- self.y = y
- self.radius = r
- self.kot = []
- def simplify_angle(self):
- i = 0
- j = 0
- dolzina = len(self.kot)
- #print(self.kot, dolzina)
- while i < dolzina:
- while j < dolzina and i < dolzina:
- if i != j and self.kot[j][0] >= self.kot[i][0]:
- if self.kot[j][0] > self.kot[i][1]:
- #they are not touching
- j += 1
- continue
- if self.kot[j][1] <= self.kot[i][1]:
- #this means the angle is contained, delete it
- dolzina -= 1
- del self.kot[j]
- i,j = 0,0
- continue
- #print(self.kot[i], self.kot[j])
- self.kot[i][1] = self.kot[j][1]
- #we extend the first arc, so it's 1st + 2nd
- dolzina -= 1
- del self.kot[j]
- i,j = 0,0
- #print(self.kot, i, j)
- continue
- j += 1
- j = 0
- i += 1
- #print (self.kot)
- def addup(self):
- #print (self.kot)
- probability = 0
- for i in self.kot:
- probability+=i[1]-i[0]
- return 1-probability/(2*math.pi)
- vsi = []
- for _ in range(stevilo):
- x,y,r = map(int, input().split())
- vsi.append(strelci(x, y, r))
- probability = []
- for i in range(len(vsi)):
- for j in range(len(vsi)):
- if i != j:
- razdalja = math.hypot(vsi[i].x-vsi[j].x, vsi[i].y-vsi[j].y)
- angle = math.asin(vsi[j].radius/razdalja)
- #center_angle = math.asin((vsi[j].y-vsi[i].y)/razdalja)
- center_angle = phase(complex(vsi[j].x-vsi[i].x, vsi[j].y-vsi[i].y))
- if center_angle < 0:
- center_angle = math.pi-center_angle
- #print (center_angle-angle, center_angle+angle)
- if center_angle-angle > 0:
- vsi[i].kot.append([center_angle-angle, center_angle+angle])
- else:
- vsi[i].kot.append([center_angle-angle+2*math.pi, 2*math.pi])
- vsi[i].kot.append([0, center_angle+angle])
- vsi[i].simplify_angle()
- probability.append(vsi[i].addup())
- i = 1
- for x in probability:
- i*=x
- print("%.6f"%round(i,6))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement