using
System;
using
System.Collections.Generic;
using
System.Linq;
public
class
Pair {
public
int
x;
public
int
y;
public
Pair(
int
x,
int
y)
{
this
.x = x;
this
.y = y;
}
}
public
class
GFG{
public
static
int
gcd(
int
a,
int
b)
{
if
(b == 0)
return
a;
return
gcd(b, a % b);
}
public
static
Pair getReducedForm(
int
dy,
int
dx)
{
int
g = gcd(Math.Abs(dy), Math.Abs(dx));
bool
sign = (dy < 0) ^ (dx < 0);
Pair res =
new
Pair(0, 0);
if
(sign) {
res.x = -Math.Abs(dy) / g;
res.y = Math.Abs(dx) / g;
}
else
{
res.x = Math.Abs(dy) / g;
res.y = Math.Abs(dx) / g;
}
return
res;
}
static
public
int
minLinesToCoverPoints(
int
[,] points,
int
N,
int
xO,
int
yO){
HashSet<
string
> st =
new
HashSet<
string
>();
Pair temp;
int
minLines = 0;
for
(
int
i = 0; i < N; i++) {
int
curX = points[i,0];
int
curY = points[i,1];
temp = getReducedForm(curY - yO, curX - xO);
String tempString = temp.x +
","
+ temp.y;
if
(st.Contains(tempString) ==
false
) {
st.Add(tempString);
minLines += 1;
}
}
return
minLines;
}
static
public
void
Main (){
int
xO, yO;
xO = 1;
yO = 0;
int
[,] points =
new
int
[,] { { -1, 3 },
{ 4, 3 },
{ 2, 1 },
{ -1, -2 },
{ 3, -3 } };
int
N = points.GetLength(0);
Console.Write(minLinesToCoverPoints(points, N, xO, yO));
}
}