#P2026. Find the Equation of a Line Through Two Points

    ID: 15308 Type: Default 1000ms 256MiB

Find the Equation of a Line Through Two Points

Find the Equation of a Line Through Two Points

Given two points with integer coordinates, determine the analytic expression of the line passing through these points. The line is a first-order function (linear function) and its equation is given in the form:

$$y = mx + c$$

Here, \(m\) is the slope and \(c\) is the y-intercept. You are required to compute \(m = \frac{y_2-y_1}{x_2-x_1}\) and \(c = y_1 - m \times x_1\). Note that the two given points will have distinct x-coordinates so that the slope is well-defined.

inputFormat

The input contains four integers separated by spaces: x1 y1 x2 y2, where \((x_1, y_1)\) and \((x_2, y_2)\) are the coordinates of the two points.

outputFormat

Output the equation of the line in the format: y = mx + c. If the y-intercept \(c\) is negative, output it as y = mx - |c| (with the absolute value of \(c\)). For numbers that are mathematically integers, output them as integers; otherwise, output them in decimal format.

sample

0 0 1 1
y = 1x + 0