int extend(int x,int p) {
int np=++tot;sam[np].len=sam[p].len+1;
while (p&&!sam[p].son[x]) sam[p].son[x]=np,p=sam[p].pr;
if (!p) sam[np].pr=1;else {
int q=sam[p].son[x];
if...
分类:
其他好文 时间:
2016-08-17 23:09:48
阅读次数:
146
import numpy as np a = np.array([[1, 2], [3, 4]]) a.shape Out[3]: (2, 2) b = np.array([[5, 6]]) b.shape Out[5]: (1, 2) np.concatenate((a, b)) Out[6]: ...
分类:
其他好文 时间:
2016-08-12 01:03:46
阅读次数:
213
# -*- coding: utf-8 -*- """ Created on Thu Aug 11 18:54:12 2016 @author: Administrator """ import numpy as np import matplotlib.pyplot as plt from skl ...
分类:
其他好文 时间:
2016-08-11 22:24:47
阅读次数:
434
今天在阅读数学建模的时候看到了差分那章 其中有一个用matlab求线性的代码,这里我贴出来 这里我送上 Python代码 In [39]: import numpy as np ...: from scipy.optimize import nnls ...: x = np.array([[1,2, ...
分类:
编程语言 时间:
2016-08-09 21:59:02
阅读次数:
1273
使用sklearn中的函数可以很方便的将数据划分为trainset 和 testset 该函数为sklearn.cross_validation.train_test_split,用法如下: >>> import numpy as np >>> from sklearn.cross_validati ...
分类:
编程语言 时间:
2016-07-24 17:35:41
阅读次数:
1786
基于lanny一键安装包:(含lnmp所需软件及配置文件) 安装nginx: 安装mysql:(集成) 安装php: nginx支持 php 完整的bbs配置:/application/nginx/conf/extra/bbs.conf server { listen 80; server_name ...
分类:
数据库 时间:
2016-07-22 10:09:08
阅读次数:
233
1 # coding:utf-8 2 import numpy as np 3 import matplotlib.pyplot as plt 4 5 def dis(x, y): #计算距离 6 return np.sum(np.power(y - x, 2)) 7 8 def dataN(len ...
分类:
编程语言 时间:
2016-07-20 09:08:42
阅读次数:
409
1. 通俗详细地讲解什么是P和NP问题 http://blog.sciencenet.cn/blog-327757-531546.html NP 非定常多项式(英语:non-deterministic polynomial,缩写NP)时间复杂性类,或称非确定性多项式时间复杂性类 要计算或解决一个问题 ...
分类:
其他好文 时间:
2016-07-14 21:54:15
阅读次数:
187
题意: 给你一个无向图,判断是否能够构成一个二分图,如果能的话,输出二分图左边的集合和右边的集合 分析: 先给每一个顶点的color初始化-1,表示没有被染色,用vector数组v[a],表示元素a所相连的全部元素,然后枚举每一个顶点,发现没有被染色,就对它进行染色,先把顶点染成0,然后 再将染成颜 ...
分类:
其他好文 时间:
2016-07-14 13:14:56
阅读次数:
183
原题: Description Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex coverproblem very interesting. Supp ...
分类:
其他好文 时间:
2016-07-14 01:53:38
阅读次数:
156