等腰三角形(easy) 用 python O(n3) 超时
这是为啥?
n = int(input()) points = [] for i in range(n): x, y = map(int, input().split()) points.append((x, y)) count = 0 def calc(i, j): return (points[i][0]-points[j][0])**2 + (points[i][1]-points[j][1])**2 for i in range(n): for j in range(i+1, n): distij = calc(i, j) for k in range(j+1, n): # 判断第三个点不和前面两个点共线 if (points[j][1] - points[i][1]) * (points[k][0] - points[i][0]) !=\ (points[k][1] - points[i][1]) * (points[j][0] - points[i][0]): distjk = calc(j, k) distik = calc(i, k) if distij == distik or distij == distjk or distik == distjk: count += 1 print(count)