ABC
E
Math
ABC248 E - K-colinear Line
https://atcoder.jp/contests/abc248/tasks/abc248_e (opens in a new tab)
colinear ใฏใๅ ฑ้ใฎใใฎๆๅณใ
็ฐใชใ 3 ็นใๅไธ็ด็ทไธใซใใใใฎๅคๆญใฏใๅพใใงใฏใชใใใฏใใซใ็จใใไบใๅณใก 3 ็น ใๅไธ็ด็ท็ถใซใใใจใใใใจใฏใ ใๆใ็ซใคใใคใพใ ใๆ็ซใใใใจใงใใใ
้่คใๅฆ็ใใใฎใซใใชใๆ้ๅใฃใใ ้ๅใฏใใใทใฅๅฏ่ฝใงใฏใชใใฎใงใ้ๅใฎ่ฆ็ด ใซ้ๅใๆใคไบใใงใใชใ ใใฎใใใฝใผใใใฆใใใฟใใซใซๅคๆใใฆ้ๅใซ่ฟฝๅ ใใฆใใใใใใฎใฝใผใใๅฎ่กๆ้ๅ ใซๅใพใใใฉใใใฏๆญฃ็ด่ชไฟกใใชใใฃใ
def colinear_line(x0,y0,x1,y1,x,y):
return (x1-x0)*(y-y0) == (y1-y0)*(x-x0)
n,k_ = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(n)]
ans = set()
for i in range(n):
for j in range(i+1,n):
group = []
(x1,y1),(x2,y2) = xy[i],xy[j]
group.append(i)
group.append(j)
for k in range(n):
if k == i or k == j:
continue
x,y = xy[k]
if colinear_line(x1,y1,x2,y2,x,y):
group.append(k)
group = tuple(sorted(group))
if len(group) >= k_ and group not in ans:
ans.add(group)
print(len(ans) if k_ != 1 else 'Infinity')