Problem A
Triangles of a Square
Ashley has given Brandon a square of side
Brandon wants to draw some additional line segments such that it is possible to decompose the square into a set of disjoint triangles, where each triangle has sides that are either subsegments of the sides of the square, or subsegments of any drawn line segment.
Compute the minimum number of additional line segments Brandon needs to draw to make this possible.
Input
Imagine that the square is axis-aligned with its bottom-left
corner at
Input has a single line with four integers
It is guaranteed the two end points are distinct. Both end points are on sides of the square. If the segment intersects a side of the square, it does so at exactly one point.
Output
Output a single integer, the minimum number of additional line segments Brandon needs to draw.
Sample Input 1 | Sample Output 1 |
---|---|
0 10 10 0 |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
2024 2024 0 0 |
0 |