代码如下: import random n = int(input("请输入行:")) m = int(input("请输入列:")) x = y = 0 while x < n: y = 0 while y < m: print(random.randint(1, 100), end="\t") y += 1 print() x += 1 运行结果:
很多时候会出现把一个N*M的矩阵做pca(对M降维)之后却得到一个M*(M-1)矩阵这样的结果.之前都是数学推导得到这个结论,但是, 今天看到一个很形象的解释: Consider what PCA does. Put simply, PCA (as most typically run) creates a new coordinate system by (1) shifting the origin to the centroid of your data, (2) squeezes and
A Simple Math Problem 一个矩阵快速幂水题,关键在于如何构造矩阵.做过一些很裸的矩阵快速幂,比如斐波那契的变形,这个题就类似那种构造.比赛的时候手残把矩阵相乘的一个j写成了i,调试了好久才发现.改过来1A. 贴个AC的代码: const int N=1e5+10; ll k,m,s[10]; struct mat { ll a[10][10]; }; mat mat_mul(mat A,mat B) { mat res; memset(res.a,0,sizeof(res.a