Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible o...
分类:
其他好文 时间:
2014-08-08 02:06:05
阅读次数:
207
/*
KMP算法
*/
void main()
{
putsl(find('abc123','c1'))
putsl(find('abc123','c2'))
}
int find(rstr s,rstr p)
{
next=get_next(p)
i=0
j=0
for i<s.count&&j<p.count
if j==-1||s[i]==p[j]
i++
j...
分类:
其他好文 时间:
2014-08-08 02:00:55
阅读次数:
209
void GetNextval(char* p, int next[])
{
int pLen = strlen(p);
next[0] = -1;
int k = -1;
int j = 0;
while (j < pLen - 1)
{
//p[k]表示前缀,p[j]表示后缀
...
分类:
其他好文 时间:
2014-08-07 19:12:11
阅读次数:
229
SVN环境搭建步骤如下: 从网上下载SVN的客户端和服务器,下载的时候需要注意客户端和服务器的版本需要保持一致,另外需要注意的是电脑系统为32位,需下载32位的软件,64位的相应位64位的软件。 步骤一:将下载好的客户端和服务器进行安装,基本上一直next就行了; 安装完成后检验是否安...
分类:
系统相关 时间:
2014-08-07 18:51:52
阅读次数:
384
#include#includeint next[10005],lena,lenb;int a[1000005],b[10005];void set_naxt()//子串的next数组{ int i=0,j=-1; next[0]=-1; while(i<lenb) { ...
分类:
其他好文 时间:
2014-08-07 18:26:50
阅读次数:
227
KMP,在有循环节的前提下: 循环节 t = len-next[len], 个数num = len/(len-next[len]);个人理解,如果有循环节,循环节长度必定小于等于len/2, 换句话说next[len]>=len/2;对于len%(len-next)!=0的这种情况不讨论,循环节不存...
分类:
其他好文 时间:
2014-08-07 12:14:29
阅读次数:
290
/*
全排列的非递归实现,支持去掉重复
*/
void main()
{
rbuf v
#v.push(1,2,3,4)
for
v.join('').printl
ifn next_permutation(v)
break
}
bool next_permutation(rbuf& v)
{
if v.count<=1
return false
next=v.co...
分类:
其他好文 时间:
2014-08-06 22:58:32
阅读次数:
223
转:http://xn--ghqyhzj.com/post-21537.html本文针对LNMP的PHP 版本ver 5.3.6 or Higher,其它未测试过。1. 使用不同端口或php-fpm.sock启动多个php-fpm主进程假设使用不同的配置文件启动3个创建sock监听的PHP-FPM主...
分类:
Web程序 时间:
2014-08-06 22:05:02
阅读次数:
275
问题:删除距离末尾n个距离的结点分析:先找出距离末尾n个距离的结点其距离开始的距离多少,然后再删除/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ...
分类:
其他好文 时间:
2014-08-06 21:58:02
阅读次数:
199
题目链接:http://poj.org/problem?id=2406题目大意:如果n%(n-next[n])==0,则存在重复连续子串,长度为n-next[n]。例如: a b a b a bnext:-1 0 0 1 2 3 4next[n]==4,代表着,前缀abab与后缀abab相等的最.....
分类:
其他好文 时间:
2014-08-06 17:59:31
阅读次数:
186