Linear Ecosystem
题目链接:
http://acm.hust.edu.cn/vjudge/contest/127401#problem/B
Description
http://7xjob4.com1.z0.glb.clouddn.com/99b0fe905e5bd89a24c882832c93cc09Input
The first line of the input file contains an integer, n, which is the number of ecosystems. For each case, the first line contains the integer k which is the number of comorgs. Followed by k lines, where the i-th line contains, αi,1, αi,2, . . . , αi,k, the coefficients of the transition equation for ci.Output
For each test case, output ‘1’ if the ecosystem is potentially stable, otherwise output ‘0’. Output only 5 answers per line. There should be a blank space between any two output answers.Sample Input
6 2 4 -2 -6 5 2 2 2 0 0 3 0.3 0.2 0.5 0.4 0.4 0.2 0 0.8 0.2 3 0.3 0.2 0.5 0 0 0 0 0.8 0.2 2 4 2.0 -6 5 2 1 0 0 1Sample Output
1 0 1 0 0 1##题意: 对一个k元向量, 每次左乘一个k*k的矩阵得到新的向量. 问经过一定次数的左乘后,能否使得该向量不再变化. (同时要求此时向量非零)
##题解: 设初始向量为A,矩阵为P. 由于每次矩阵P都是左乘A, 那么可以把若干个P合并. 则题目的条件是:![](http://images2015.cnblogs.com/blog/764119/201608/764119-20160817202127140-716369880.png) 化简为: ![](http://images2015.cnblogs.com/blog/764119/201608/764119-20160817202208937-417784419.png) 由于要求 ![](http://images2015.cnblogs.com/blog/764119/201608/764119-20160817202227375-207951499.png) 所以 P-1 必须不可逆. 可以直接用高斯消元求P-1的秩,判断是否可逆(满秩即可逆).
##代码: ``` cpp #include