01 2013 档案

摘要:Kmp初级应用,不解释说一下失配函数的求解,其中的j其实既维护了改进前的next,又维护了改进后的next//kmp #include <iostream> #include <cstdio> #include <string.h> using namespace std; const int maxn=2*100000+10; char s1[maxn],s2[maxn]; int nextv[maxn]; int len1,len2; void getNext() { int i=0,j=-1; nextv[0]=-1; while(i<len2- 阅读全文
posted @ 2013-01-31 11:41 LJ_COME!!!!! 阅读(130) 评论(0) 推荐(0)
摘要:此题不难,可以转化为求解区间内的个数和,树状数组比较便捷,结果大,用long long#include <iostream> #include <cstdio> #include <algorithm> #include <string.h> using namespace std; const int maxn=1000; int road[maxn+10][maxn+10]; int temp[maxn+10]; int n,m,k; long long num=0; int sumx[maxn+10]; int lowbit(int x) 阅读全文
posted @ 2013-01-26 15:31 LJ_COME!!!!! 阅读(125) 评论(0) 推荐(0)
摘要:高精度阶乘#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn=50000; int s[maxn]; int n; int main() { while(cin>>n) { int i,j,t,k; memset(s,0,sizeof(s)); s[0]=1; int c,l=1; if(n==0||n==1) printf("1"); else { for(i=2;i<=n;i++) { 阅读全文
posted @ 2013-01-25 22:41 LJ_COME!!!!! 阅读(129) 评论(0) 推荐(0)
摘要:主要是dfs,只要dfs这一步想到,也就是怎样把问题转化为区间求和,就很容易用树状数组来求解#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn= 100000; int head[maxn+10],e[maxn+10],num[maxn+10],lim[maxn+10],sumx[maxn+10],vis[maxn+10]; int nextx[maxn+10]; int n,m,tot,tem; void dfs(int x 阅读全文
posted @ 2013-01-24 19:20 LJ_COME!!!!! 阅读(147) 评论(0) 推荐(0)
摘要:线段树区间修改入门题目。快被这个长整形给整死啦。以后如果对自己的算法的正确性有80%的把握,就去看一下细节,非常认真的看一遍,一行一行的看,这样其实更省时间,就比如我这次调来调去,调了4个多小时,最后才突然发现。//线.3段树区间修改 #include <iostream> #include <stdio.h> #include <cstring> using namespace std; const int maxn=100000; __int64 sum[maxn*3],d[maxn*3]; int v[maxn+10]; int n,q; int ql 阅读全文
posted @ 2013-01-08 16:25 LJ_COME!!!!! 阅读(129) 评论(0) 推荐(0)
摘要:线段树入门题#include <iostream> #include <stdio.h> #include <memory.h> using namespace std; const int maxn=50000; const int inf=1<<30; int n,q; int minv[maxn*3],maxv[maxn*3]; void init() { for(int i=0;i<maxn*3;i++) { minv[i]=inf; maxv[i]=-1; } } void update(int no,int p,int l,in 阅读全文
posted @ 2013-01-07 18:52 LJ_COME!!!!! 阅读(124) 评论(0) 推荐(0)
摘要:虽然这道题没有用什么算法,但却锻炼了思维//矢量分解 #include <iostream> #include <cstdio> #include <cmath> using namespace std; double l,w,x,y,r,a,v,s; int main() { while(cin>>l>>w>>x>>y>>r>>a>>v>>s) { if(!l&&!w&&!x&&!y&&!r& 阅读全文
posted @ 2013-01-04 18:08 LJ_COME!!!!! 阅读(209) 评论(0) 推荐(0)
摘要:大整数取模,脑袋怎么就不开窍呢//我太愚蠢啦 #include <iostream> #include <cstring> #include <cstdio> using namespace std; char s[200]; int main() { while(gets(s)) { if(strcmp(s,"0")==0) break; int i; int len=strlen(s); int ou=0; for(i=0;i<len;i++) { ou=((ou*10)%17+(s[i]-'0')%17)%17 阅读全文
posted @ 2013-01-04 15:35 LJ_COME!!!!! 阅读(128) 评论(0) 推荐(0)
摘要:这题不难,没有涉及算法。主要是熟练了一下指针。主要思想就是,设定一个规范模式,然后朝着这个规范模式化解,代码可以优化,有许多冗余 的地方。#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn=1000000; char sa[maxn],sb[maxn]; int main() { while(scanf("%s %s",sa,sb)!=EOF) { getchar(); int len1=strlen(sa 阅读全文
posted @ 2013-01-03 17:12 LJ_COME!!!!! 阅读(128) 评论(0) 推荐(0)
摘要:树状数组#include <iostream> #include <string.h> #include <stdio.h> using namespace std; const int maxn1=100000; const int maxn2=20010; int c[maxn1+10],v[maxn2],l[maxn2],r[maxn2]; int n; int lowbit(int x) { return x&(-x); } void add(int x) { while(x<=maxn1)//要细心 { c[x]+=1; x+=low 阅读全文
posted @ 2013-01-01 18:53 LJ_COME!!!!! 阅读(144) 评论(0) 推荐(0)