"you can't add apples and oranges."「你不能把蘋果和橘子加在一起」
The central porblem of linear algebra is to solve a system of equations.
It is also common sense: If you put on socks and then shoes, the first to be taken off are the ___.
Ax combines the columns of A while xTAT combines the rows of AT
--談為何(AB)T = BTAT 最近看Gilbert Strang寫的『Introduction to Linear Algebra』，Strang教授講法生動，不論是趣味的例子，或者是一句話直搗觀念核心，都常讓我拍案叫絕。 比起補習班名師的講義，研讀起來樂趣大多了。有機會再補上更多句子。
Well, I'll assume you understand what the problem asks. You have to find the shortest sequence that yelds a profit (not the one with the greatest profit!). If there is more then one sequence with the same length, any of those is valid.
Now, you can't just try with brute force (trying all combinations) because it'll be too slow and you'll get Time Limit Exceeded. However, there's a well known algorithm, Floyd-Warshall, which will find all the shortest paths between every node to the others in just O(n^3) time. You can find more info about F-W in the net. In my previous post I said how you have to change the general F-W algorithm to work for this particular problem...
As for floating point errors, most numbers representation isn't totally acurate; for instance, 0.1 is usually stored as 0.10000000000000001. After some operations, the error may influence the final result. Again, search th…