cswork / OA打开练习工作台

GreyOrangeOA #3

Triangle and Points

估计简单评测数据准备中,可先阅读题面

考点(AI 标注)位运算

You are given the coordinates of a triangle with three vertices:

  • (x1, y1)
  • (x2, y2)
  • (x3, y3) Additionally, you are provided the coordinates of two points:
  • Point p: (xp, yp)
  • Point q: (xq, yq) Your task is to determine the following:
  • Print '1' if the triangle cannot be formed.
  • Print '2' if both p and q lie inside the triangle.
  • Print '3' if only point p lies within the triangle.
  • Print '4' if only point q lies within the triangle.
  • Print '5' if neither point lies inside the triangle. Input Format:
  • Coordinates of the triangle vertices: x1, y1, x2, y2, x3, y3
  • Coordinates of the points p and q: p(xp, yp), q(xq, yq)

Example 1

Input:

x1 = 0
y1 = 0
x2 = 5
y2 = 0
x3 = 0
y3 = 5
xp = 1
yp = 1
xq = 6
yq = 6

Output:

3

Explanation: Only point p lies inside the triangle.