102484: [AtCoder]ABC248 E - K-colinear Line

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $500$ points

Problem Statement

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

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

Constraints

  • $1 \leq K \leq N \leq 300$
  • $\lvert X_i \rvert, \lvert Y_i \rvert \leq 10^9$
  • $X_i\neq X_j$ or $Y_i\neq Y_j$, if $i\neq j$.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $K$
$X_1$ $Y_1$
$X_2$ $Y_2$
$\vdots$
$X_N$ $Y_N$

Output

Print the number of lines in the plane that pass $K$ or more of the $N$ 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=0$, $y=0$, $y=x\pm 1$, and $y=-x\pm 1$ satisfy the requirement.
For example, $x=0$ passes the first, third, and fifth points.

Thus, $6$ 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.

Input

题意翻译

给定平面直角坐标系上的 $N$ 个点,第 $i$ 个点的坐标为 $(x_i,y_i)$,问有多少条直线至少经过了 $K$ 个点。

Output

得分:500分 部分 问题描述 你得到了平面上的N个点。 对于每个1≤i≤N,第i个点在坐标(Xi,Yi)处。 找到通过平面上N个点中的K个或更多的线的数量。 如果有无限多条这样的线,请打印 Infinity 。 部分 约束条件 1≤K≤N≤300 |Xi|,|Yi|≤10^9 如果i≠j,则Xi≠Xj或Yi≠Yj。 输入中的所有值都是整数。 部分 输入 输入格式如下,从标准输入中给出: N K X1 Y1 X2 Y2 …… XN YN 部分 输出 打印通过平面上N个点中的K个或更多的线的数量,如果这样的线有无限多条,则打印 Infinity 。 部分 样例输入1 5 2 0 0 1 0 0 1 -1 0 0 -1 部分 样例输出1 6 六条线x=0,y=0,y=x±1和y=-x±1满足要求。 例如,x=0通过第一个、第三个和第五个点。 因此,应打印6。 部分 样例输入2 1 1 0 0 部分 样例输出2 Infinity 有无限多条线通过原点。 因此,应打印 Infinity 。

加入题单

算法标签: