class
GFG
{
static
class
point
{
int
x, y;
public
point(
int
x,
int
y)
{
super
();
this
.x = x;
this
.y = y;
}
};
static
class
line
{
public
line(
int
a,
int
b,
int
c)
{
this
.a = a;
this
.b = b;
this
.c = c;
}
int
a, b, c;
line()
{}
};
static
int
evalPointOnLine(point p, line curLine)
{
int
eval = curLine.a* p.x +
curLine.b * p.y +
curLine.c;
if
(eval >
0
)
return
1
;
return
-
1
;
}
static
int
minJumpToReachDestination(point start,
point dest, line lines[],
int
N)
{
int
jumps =
0
;
for
(
int
i =
0
; i < N; i++)
{
int
signStart = evalPointOnLine(start, lines[i]);
int
signDest = evalPointOnLine(dest, lines[i]);
if
(signStart * signDest <
0
)
jumps++;
}
return
jumps;
}
public
static
void
main(String[] args)
{
point start =
new
point(
1
,
1
);
point dest =
new
point(-
2
, -
1
);
line []lines =
new
line[
3
];
lines[
0
] =
new
line(
1
,
0
,
0
);
lines[
1
] =
new
line(
0
,
1
,
0
);
lines[
2
] =
new
line(
1
,
1
, -
2
);
System.out.print(minJumpToReachDestination(start, dest, lines,
3
));
}
}