Description Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak. Given a n × n matrix A and a positive integer k, f ...
分类:
其他好文 时间:
2018-03-04 16:07:13
阅读次数:
159
一、问题描述 给定一个矩阵、要求螺旋型输出矩阵结果。 例子:给定矩阵[[1,2,3],[4,5,6],[7,8,9]]。输出结果为1,2,3,6,9,8,7,4,5。 二、问题解决 将矩阵分解成多个嵌套的空心矩形来遍历,将每个空心矩形的遍历分为四个部分:向右增长,向下增长,向左增长,向上增长。(代码 ...
分类:
其他好文 时间:
2018-03-04 16:06:29
阅读次数:
201
在MCMC(一)蒙特卡罗方法中,我们讲到了如何用蒙特卡罗方法来随机模拟求解一些复杂的连续积分或者离散求和的方法,但是这个方法需要得到对应的概率分布的样本集,而想得到这样的样本集很困难。因此我们需要本篇讲到的马尔科夫链来帮忙。 1. 马尔科夫链概述 马尔科夫链定义本身比较简单,它假设某一时刻状态转移的 ...
分类:
其他好文 时间:
2018-03-04 16:02:56
阅读次数:
283
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted i ...
分类:
其他好文 时间:
2018-03-03 21:52:21
阅读次数:
185
spoj 104 Highways 生成树计数,matrix-tree定理的应用。 Matrix-tree定理: D为无向图G的度数矩阵(D[i][i]是i的度数,其他的为0),A为G的邻接矩阵(若u,v之间存在边,A[u][v]=A[v][u]=1),C=D-A。 对于一个无向图G,它的生成树个数 ...
分类:
其他好文 时间:
2018-03-03 21:21:01
阅读次数:
156
#include <iostream>#include <string>#include <cstdio>using namespace std; #define MaxVnum 50typedef double A_Matrix[MaxVnum][MaxVnum];typedef struct{ ...
分类:
编程语言 时间:
2018-03-03 18:16:12
阅读次数:
129
开始没看到要求对角线以外的地方不能是0,以为是个xx题。。。照着题解思路写的,很妙啊 题意:给定01矩阵 求矩阵中最长的只有对角线是1的正方形的对角线长度 x[i][j]从(i,j)向左/右(不包括(i,j))的连续的0的数量 y[i][j]从(i,j)向上(不包括(i,j))的连续的0的数量 1 ...
分类:
其他好文 时间:
2018-03-03 14:12:51
阅读次数:
159
A museum was represented by a square matrix that was filled with O, G, and W where O represented open space, G represented guards, and W represented w ...
分类:
其他好文 时间:
2018-03-02 10:23:10
阅读次数:
189
如果不谈证明,稍微有点线代基础的人都可以在两分钟内学完所有相关内容。。 行列式随便找本线代书看一下基本性质就好了。 学习资源: https://www.cnblogs.com/candy99/p/6420935.html http://blog.csdn.net/Marco_L_T/article/ ...
分类:
其他好文 时间:
2018-02-28 01:08:12
阅读次数:
1486
AC自动机+矩阵乘法 套路$dp$,也就是从$root$开始走n步不经过危险节点 这不就是经典的倍增$floyd$吗,trie图是有向图 AC自动机真是个奇怪的东西,不能识别的子串都属于根节点 #include <cstdio> #include <cstring> #include <algori ...
分类:
其他好文 时间:
2018-02-27 21:20:57
阅读次数:
202