import numpy as np # 改好的!!!!!!!!!!!!!!!!!!!!!!!!!! def canget(A): n = A.shape[0] P = A for i in range(2, n + 1): P = P + np.linalg.matrix_power(A, i) P = (P != 0).astype(int) return P