Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/begin-tenglamalar-sistemasi

System of equations

Medium 1000 ms 64 MB 38%
Share

A system of two linear equations in two unknowns is given:

$$\begin{cases} a_{1} * x + b_{1} * y = c_{1} \\ a_{2} * x + b_{2} * y = c_{2} \end{cases}$$

The determinant $D = a_{1} * b_{2} - a_{2} * b_{1}$ is non-zero, so the solution is unique. Find $x$ and $y$ with Cramer's rule:

$$x = \frac{c_{1} * b_{2} - c_{2} * b_{1}}{D}, \qquad y = \frac{a_{1} * c_{2} - a_{2} * c_{1}}{D}$$

Two lines cross at one point; the coordinates (x; y) of that point are the solution of the system

Input

The first line has three integers: $a_{1}$, $b_{1}$ and $c_{1}$. The second line has three integers: $a_{2}$, $b_{2}$ and $c_{2}$.

Output

One line with two numbers: $x$ and $y$, each with exactly 2 digits after the decimal point (for example, 2.00). If the rounded result is zero (for example, $-0.001$), print 0.00 (not -0.00).

Note

$-1000 \le a_{1}, b_{1}, c_{1}, a_{2}, b_{2}, c_{2} \le 1000$
$a_{1} * b_{2} - a_{2} * b_{1} \ne 0$

Examples

Input #1
1 1 3
1 -1 1
Output #1
2.00 1.00
Input #2
2 3 7
4 -1 0
Output #2
0.50 2.00

Sign in to submit a solution

Signing up is free and takes a minute.