图普科技2018届秋招在线笔试 register

Ended

Participants:463

Verdict:Runtime Error
Score:10 / 100
Submitted:2017-10-15 14:44:32

Lang:Python2

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-
import math
def distance_point(ab):
    return math.sqrt(float(a[0] - b[0])**2 + float(a[1] - b[1])**2)
def get_line(linep1linep2):
    A = linep2[1] - linep1[1]
    B = linep1[0] - linep2[0]
    C = -(A * linep1[0] + B * linep1[1])
    return ABC
def distance_line(alinep1linep2):
    ABC = get_line(linep1linep2)
    if A == B == 0:
        return distance_point(alinep1)
    dis = abs(A * a[0] + B * a[1] + C) / math.sqrt(A**2 + B**2)
    return dis
def p_in_tri(pt):
    dis_p2ts = map(lambda xdistance_point(px)t)
    bianchang = [distance_point(t[0]t[1])distance_point(t[0]t[2]),
                 distance_point(t[1]t[2])]
    areas = [0.5 * bianchang[0] * distance_line(pt[0]t[1]),
             0.5 * bianchang[1] * distance_line(pt[0]t[2]),
             0.5 * bianchang[2] * distance_line(pt[1]t[2])]
    if sum(areas) <= 0.5 * bianchang[0] * distance_line(t[2]t[0]t[1]):
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX