大疆机器学习算法工程师B卷
  编程题åc了91%,有没有人都对的帮我看看哪些corner case没考虑到? 
    
  
import math
while 1:
	a=[]  
	s = input()
	if s != "":
		for x in s.split():  
			a.append(int(x))  
	r, circle_x, circle_y, x1, y1, x2, y2 = a
	rec_x, rec_y = (x1+x2)/2, (y1+y2)/2
	distance = math.sqrt((circle_x-rec_x)**2 + (circle_y-rec_y)**2)
	if abs(circle_y - rec_y) == 0:
		distance_2 = (x2 - x1)/2 
	elif abs(circle_x-rec_x) == 0:
		distance_2 = (y2 - y1)/2 
	else:
		tan1 = abs(circle_y - rec_y) / abs(circle_x-rec_x)
		tan2 = (y2 - y1) / (x2 - x1)
		if tan1 < tan2:
			#abs(circle_x-rec_x) / distance = (x2-x1)/2 / distance_2
			distance_2 = distance * (x2-x1)/2 / abs(circle_x-rec_x)
			
		if tan1 >= tan2:
			#abs(circle_y-rec_y) / distance = (y2-y1)/2 / distance_2
			distance_2 = distance * (y2-y1)/2 / abs(circle_y-rec_y)
		
	if distance_2 + r < distance:
		print('False')
		
	else:
		print('True')     
  
 投递宇宙厂等公司10个岗位
投递宇宙厂等公司10个岗位 查看12道真题和解析
查看12道真题和解析