cswork / OA打开练习工作台

Goldman SachsOA #29

Do They Belong?

估计中等可在线判题

考点(AI 标注)位运算

Given a triangle formed by three vertices and the points p and q. Return 0 for a degenerate triangle; otherwise return 1, 2, 3, or 4 depending on whether p and q lie inside the triangle or on its boundary.

输入格式

A single line containing x1 y1 x2 y2 x3 y3 xp yp xq yq in order; all coordinates are integers in 0..2000.

输出格式

Return 0..4 according to the cases in the statement: 1 = only p is inside/on the boundary, 2 = only q is inside/on the boundary, 3 = both points are, 4 = neither point is.

样例 1

输入:

0 0 4 0 0 4 1 1 4 4

输出:

1

样例 2

输入:

0 0 3 0 0 3 1 1 4 4

输出:

1

样例 3

输入:

0 0 2 2 4 4 1 1 0 0

输出:

0