zltzlt 发表于 2020-3-31 17:50:44

旅途Z 发表于 2020-3-31 17:48
已修改,我测试的时候把输入列表转变成了数组,忘了在函数里把list变成数组了TAT

OK,3516 ms

kinkon 发表于 2020-3-31 18:11:15

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

zltzlt 发表于 2020-3-31 18:12:39

kinkon 发表于 2020-3-31 18:11
敲错啦

92 ms

死骑Reynolds 发表于 2020-3-31 19:49:02

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))
页: 1 2 [3]
查看完整版本: Python:每日一题 362