Computer Science, asked by shaiksanatabassum999, 6 months ago

Signal Connection Problem Description You have been given longitude and latitude of locations from where the channels are going to be broadcasted. You also get the height of tower from which these channels are broadcasted. Moreover, you have been given the location of your friend Jason. You have to calculate how many connections he can make to the towers. Take Radius of earth= 6371 KM. All the computation has to be accurate up to 6 digits after the decimal point. Constraints 1 <= N < 10^5 Input First line contains integer N denoting the number of locations from where the channel is going to be broadcasted Second line contains N space-separated decimal values denoting latitudes Third line contains N space-separated decimal values denoting longitudes Fourth line contains N space-separated integer values denoting the height of tower from which channels are broadcasted Fifth Line contains two space-separated decimal values denoting latitude, longitude of Jason's location Output Print the number of channels Jason can connect with Time Limit 1 Examples Example 1 Input 2 19.076090 17.387140 72.877426 78.491684 2 1 18.516726 73.856255 Output 1 Explanation First latitude and longitude is Mumbai and second is for Hyderabad from where the channel signals are broadcasted. Jason is in Pune. According to signal strength Jason will only be able to connect Mumbai tower. Example 2 Input 2 28.644800 22.572645 77.216721 88.363892 5 7 48.864716 2.349014 Output 0 Explanation First latitude and longitude is Delhi and second is for Kolkata from where the channel signals are broadcasted. Jason is in Paris. According to signal strength Jason will not be able to connect any tower.

Answers

Answered by Swati2667
5

IS IT A QUESTION OR A STORY

Answered by pankhaniyajay
10

Answer:

try:

n=int(input())

input()

lat=list(map(float,input().split()))

input()

long=list(map(float,input().split()))

input()

height=list(map(int,input().split()))

input()

jason=list(map(float,input().split()))

input()

radius=6371

tower=list(zip(lat,long,height))

def reach(heig):

val=2*heig*radius

dist=pow(val,0.5)

return dist

from math import radians, cos, sin, asin, sqrt

def distance(lat1, lat2, lon1, lon2):

lon1 = radians(lon1)

lon2 = radians(lon2)

lat1 = radians(lat1)

lat2 = radians(lat2)

# Haversine formula

dlon = lon2 - lon1

dlat = lat2 - lat1

a = sin(dlat / 2) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2) ** 2

c = 2 * asin(sqrt(a))

return c * radius

def possible(tow,jas):

x=reach(tow[2])

y=distance(tow[0],jas[0],tow[1],jas[1])

return y<=x

count=0

for i in range(n):

if possible(tower[i],jason):

count+=1

print(count)

except :

pass

Similar questions