gate 一年前做的. 求一个字符串由多少个循环节构成. KMP. 结论:若$n % (n-next[n]) \not= 0$则不是由循环节构成的. 否则,答案为$n/(n-next[n])$. code #include<cstdio> #include<iostream> #include<cm ...
分类:
其他好文 时间:
2020-07-01 09:51:14
阅读次数:
65
给定一个 m x n 的矩阵,如果一个元素为 0,则将其所在行和列的所有元素都设为 0。请使用原地算法。 function setZeroes(matrix) { let x = [],y = [] for(let i = 0;i < matrix.length;i++){ let item = m ...
分类:
其他好文 时间:
2020-06-30 22:41:28
阅读次数:
46
int prime[maxn], prime_tot; int is_prime[maxn]; int mu[maxn]; void pre_calc(int lim) { mu[1] = 1; for (int i = 2; i <= lim; i++) { if (!is_prime[i]) { ...
分类:
其他好文 时间:
2020-06-30 20:43:31
阅读次数:
49
稀疏 sparsearray 数组 简介 矩阵中非零元素的个数远远小于矩阵元素的总数,并且非零元素的分布没有规律,通常认为矩阵中非零元素的总数比上矩阵所有元素总数的值小于等于0.05时,则称该矩阵为稀疏矩阵(sparse matrix),该比值称为这个矩阵的稠密度; 当一个数组中大部分元素为0,或者 ...
分类:
编程语言 时间:
2020-06-29 22:43:01
阅读次数:
61
问题: 给定由0,1构成的数组,求由1构成的(各种长度边长的)正方形的总个数有多少。 Example 1: Input: matrix = [ [0,1,1,1], [1,1,1,1], [0,1,1,1] ] Output: 15 Explanation: There are 10 squares ...
分类:
其他好文 时间:
2020-06-29 20:05:12
阅读次数:
61
luoguP6620 [省选联考 2020 A 卷] 组合数问题(斯特林数) Luogu 题外话: LN切这题的人比切T1的多。 我都想到了组合意义乱搞也想到可能用斯特林数为啥还是没做出来。。。 我怕不是除了数据结构啥也不会。 我是傻逼。 题解时间 不弄纯柿子推导,来点阳间的组合意义证明。 首先毫无 ...
分类:
其他好文 时间:
2020-06-28 20:32:39
阅读次数:
42
1.使用SQL参照 JSP新闻列表显示 2.新增web项目,项目名称为ssmNewsList 基本项目结构如下: 3.分别创建applicationContext-dao.xml、applicationContext-service.xml、applicationContext-transactio ...
分类:
其他好文 时间:
2020-06-27 13:34:52
阅读次数:
96
//给定一个二维数组,其每一行从左到右递增排序,从上到下也是递增排序。给定一个数,判断这个数是否在该二维数组中。 //要求时间复杂度 O(M + N),空间复杂度 O(1)。其中 M 为行数,N 为 列数。 //该二维数组中的一个数,小于它的数一定在其左边,大于它的数一定在其下边。因此,从右上角开始 ...
分类:
编程语言 时间:
2020-06-27 11:51:56
阅读次数:
72
恢复内容开始 Range Sum Query 2D - Immutable (M) 题目 Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left cor ...
分类:
其他好文 时间:
2020-06-27 09:36:59
阅读次数:
61
课程介绍:Data science is a "concept to unify statistics, data analysis, machine learning and their related methods" in order to "understand and analyze ac ...
分类:
其他好文 时间:
2020-06-26 22:40:13
阅读次数:
63