Number of solution of three variable equation

165 Views Asked by At

I have two equations of the form :

$ax + by + cz = k$ and $x + y + z = n$

I need to find the number of solutions of these equations. Here $a, b, c, k$ can range from $10^{-9}$ to $10^9$ and $n$ ranges from $1$ to $10^5$.

Actually the original problem was something else but I kind of boiled it down till here. No idea if this is even feasible to calculate, just giving it a shot here. I know the usual dynamic programming based solution can solve it but the constraints won't actually allow to use such a approach. Thus I thought of maybe finding a mathematical answer to it.

Also, there's just one more catch here, a solution will be different for different choice of variable. Don't really know how to state this but for example, suppose an answer is $(1, 1, 1)$, then which $1$ is assigned to which variable also matters. So here this will actually count as three different answers.

To say again, don't really know if it is feasible to even solve, but if someone has some trick or some kind of answer to it, I'd really appreciate it.

3

There are 3 best solutions below

10
On BEST ANSWER

The two equations describe (presumably distinct) planes. The planes are parallel if the vectors normal to them are parallel. This occurs if the ratios of the coefficients are the same: $$a:b:c=1:1:1$$ In other words, if $a=b=c$, there is no solution, assuming the planes are distinct. If the planes are not distinct, then $k=an$ and there are an infinite number of solutions. But if this is the case, both of your equations would be identical (up to a constant factor).

Otherwise, the two planes intersect an infinite number of times along a line.

1
On

The system is underdetermined, so it has either no solution or an infinite number of them. There is no solution when $a=b=c$ but $k\ne an$.

2
On

You should be ashamed for successfully cheating in ongoing Hackerearth June Coding Circuits.