#abc248e. E - K-colinear Line

E - K-colinear Line

Score : 500500 points

问题描述

你被给定坐标平面上的 NN 个点。对于每个 1iN1\leq i\leq N,第 ii 个点位于坐标 (Xi,Yi)(X_i, Y_i)

找出通过这 NN 个点中至少 KK 个点的直线的数量。

如果存在无限多条这样的直线,请输出 Infinity

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given NN points in the coordinate plane. For each 1iN1\leq i\leq N, the ii-th point is at the coordinates (Xi,Yi)(X_i, Y_i).

Find the number of lines in the plane that pass KK or more of the NN points.
If there are infinitely many such lines, print Infinity.

Constraints

  • 1KN3001 \leq K \leq N \leq 300
  • Xi,Yi109\lvert X_i \rvert, \lvert Y_i \rvert \leq 10^9
  • XiXjX_i\neq X_j or YiYjY_i\neq Y_j, if iji\neq j.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

X1X_1 Y1Y_1

X2X_2 Y2Y_2

\vdots

XNX_N YNY_N

Output

Print the number of lines in the plane that pass KK or more of the NN points, or Infinity if there are infinitely many such lines.

Sample Input 1

5 2
0 0
1 0
0 1
-1 0
0 -1

Sample Output 1

6

The six lines x=0x=0, y=0y=0, y=x±1y=x\pm 1, and y=x±1y=-x\pm 1 satisfy the requirement.
For example, x=0x=0 passes the first, third, and fifth points.

Thus, 66 should be printed.

Sample Input 2

1 1
0 0

Sample Output 2

Infinity

Infinitely many lines pass the origin.

Thus, Infinity should be printed.

update @ 2024/3/10 10:37:12