#include
#include
#include
typedef struct
{ char *ch;
int length;
}HString;
void StrAssign(HString &T,char chars[]);
int get_next(HString T,int next[]);
void main()
{ HString T;
char chars[80];
in...
分类:
其他好文 时间:
2014-08-01 13:51:23
阅读次数:
229
UVA 1328 - Period
题目链接
题意:给定一个字符串,求出有几个位置的前缀串是由个数大于1的串循环得到的,求出位置和循环次数
思路:利用kmp的next数组的性质,i - next[i]就是循环长度,然后判断一下是不是正好是倍数即可
代码:
#include
#include
const int N = 1000005;
int n, next[...
分类:
其他好文 时间:
2014-08-01 13:49:11
阅读次数:
171
Next time you see a numeric problem has a too straightforward solution, think about optimized one.Like this one: recursion\iteration is tooo slow. SoD...
分类:
其他好文 时间:
2014-08-01 06:57:01
阅读次数:
279
Populating Next Right Pointers in Each NodeGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLi...
分类:
其他好文 时间:
2014-07-31 23:25:40
阅读次数:
292
Populating Next Right Pointers in Each Node IIFollow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any ...
分类:
其他好文 时间:
2014-07-31 23:16:30
阅读次数:
182
淘宝API开发平台,经过两年多的升级一系列动作,提供的api接口日渐稳定。看到淘宝api开发的浏览量还是较大,但那会写的DEMO现在已不能运行,淘宝改了链接地址,改了加密算法,为了不让大家浪费时间,特意在淘宝开发社区重新注册,网站截图如下,(http://open.taobao.com/)成为开发者,按照提示一路next,终于注册成功并获得APPkey。
为开发做...
解题报告
字典树爆。
#include
#include
#include
using namespace std;
int k,e,num[100],cnt;
struct node
{
int v;
node *next[26];
};
node *newnode()
{
node *p=new node;
p->v=0;
int i;
...
分类:
其他好文 时间:
2014-07-31 20:46:07
阅读次数:
216
/** * 假设现在文本串S匹配到 i 位置,模式串P匹配到 j 位置 如果j = -1,或者当前字符匹配成功(即S[i] == * P[j]),都令i++,j++,继续匹配下一个字符; 如果j != -1,且当前字符匹配失败(即S[i] != P[j]),则令 i 不变,j = * next[j]...
分类:
编程语言 时间:
2014-07-31 16:28:46
阅读次数:
255
#include #include #include #define MAX 27typedef struct node{ int v; struct node *next[MAX];}Trie;Trie *root;void creatTrie(char *str){ int i...
分类:
其他好文 时间:
2014-07-31 16:23:26
阅读次数:
212
1 public boolean hasCycle(ListNode head) { 2 ListNode s=head; 3 ListNode f=head; 4 while(f!=null&&f.next!=null){ 5 ...
分类:
其他好文 时间:
2014-07-31 16:14:27
阅读次数:
223