随笔分类 - kmp+博弈+二叉树
摘要:/*给你n个数,让你构建一个哈弗曼树,求哈弗曼编码的长度解:就是求除了叶子节点以外的所有节点的权值和*/#include#includeusing namespace std;typedef long long inta;struct node{ inta weight; bool operator...
阅读全文
摘要:#includeint main() { int n,p,q,k; while(scanf("%d%d%d",&n,&p,&q)!=EOF) { k=n%(p+q); if(k<=p&&k!=0) printf("LOST\n"); else printf("WIN\n"); }...
阅读全文
摘要:#include#includechars[11000],t[1100000];intnext[11000];voidgetkmp(intlen) {intj,k;next[0]=-1;j=0;k=-1;while(j<len) {if(k==-1||s[k]==s[j]) {j++;k++;if(...
阅读全文
摘要:http://blog.163.com/qhx_405/blog/static/6338992620098140352928/
阅读全文
摘要:#include#include#define N 100#define INF 2000000000int b[N]; char s[100001];struct nodee{ int parent,lson,rson,visit,weight;}a[N];int main() { int ...
阅读全文
摘要:http://blog.chinaunix.net/uid-26833883-id-3158234.html
阅读全文
摘要://http://www.cnblogs.com/bo-tao/archive/2012/04/16/2452633.html#include#includeint main() { int a,b,c; while(scanf("%d%d",&a,&b)!=EOF) { if(a<b) {...
阅读全文
摘要:#include#define N 51000void getkmp(int next[],char s[]) { int j=0,k=-1; next[0]=-1; while(s[j]!=0) {if(k==-1||s[j]==s[k]) {j++;k++;if(s[j]!=s[k])next[...
阅读全文
摘要:#include#include#define N 100100void getnext(int next[],char s[]) { int k=-1,j=0;next[0]=-1;while(s[j]!=0) {if(k==-1||s[j]==s[k]) {j++;k++;if(s[j]!=s...
阅读全文
摘要:http://www.cppblog.com/oosky/archive/2006/07/06/9486.html#includeint a[10010],b[1000100],n,m,next[10010];void getnext() {int j=0,k=-1;next[0]=-1;while...
阅读全文
浙公网安备 33010602011771号