旅途Z 发表于 2020-3-31 17:48
已修改,我测试的时候把输入列表转变成了数组,忘了在函数里把list变成数组了TAT
OK,3516 ms
zltzlt 发表于 2020-3-31 17:22
form ?
敲错啦{:5_109:}
from itertools import combinations as cb
def f361(points):
return max(abs((x0-x2)*(y1-y2)-(x1-x2)*(y0-y2)) for (x0,y0),(x1,y1),(x2,y2) in cb(points,3))/2
kinkon 发表于 2020-3-31 18:11
敲错啦
92 ms
def get_area(x,y,z):
def model(x,y):
return x ** 2 + y ** 2
def dot_product(x,y):
return x * y + x * y
x_y = model(x - y, x - y)
x_z = model(x - z, x - z)
v1 =
v1 = v1[:1] + v1
v2 =
v2 = v2[:1] + v2
return ((x_y * x_z - dot_product(v1,v2))**0.5)/2
points = input('输入点集:')
points = list(points)
count = 0
list1 = []
list2 = []
for i in points:
if i.isnumeric():
count += 1
list1.append(int(i))
if count>=2 :
count = 0
list2.append(list1)
list1 = []
points = list2
listc = []
for p in points:
listb = []
for i in points:
lista = []
for e in points:
lista.append(get_area(p,i,e))
listb.append(max(lista))
listc.append(max(listb))
print(max(listc))