Any true algorithm junkie knows that a linear system with an input vector x and an output vector y can be described by a single matrix M. Column j of M holds the outputs you get when input j is one and every other input is zero. Because the system is linear, the output for an arbitrary combination of inputs is a linear combination of the columns of M.
y=Mx
You are given the matrix M and the output vector y. Find the input x that produces that output. M is an m×n matrix, y is a column vector of size m, and the x you are looking for is a column vector of size n with exactly three non-zero entries. Written out for m=3 and n=4, the task is to find the x that satisfies this equation.
y1y2y3=m11m21m31m12m22m32m13m23m33m14m24m34x1x2x3x4
You also have to handle the case where the number of inputs n is larger than the number of outputs m. The system is then underdetermined and several different x produce the same y, but only one x has exactly three non-zero entries.
The first line contains the number of rows m of the matrix M, and the second line contains the number of columns n. Each of the next m lines contains one row of M as n real numbers separated by whitespace. Each of the following m lines contains one entry of the output vector y.
3≤m≤30, 3≤n≤30, and an x satisfying the condition always exists and is unique. One input holds a single test case.
Print the indices of the three non-zero entries in increasing order, one per line, in this format.
input i = v
i is an integer between 1 and n, and v is the value of that input rounded to two decimal places. No answer value sits close enough to a rounding boundary for the rounding direction to be in doubt.
Multiplying M by the correct x reproduces every entry of y to within a relative error of 0.01%. The non-zero entries can sit in only (3n) places, so you can solve the least squares problem for each candidate triple of columns and keep the triple whose residual is close to zero. The three indices have to match the correct answer exactly.