上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 17 下一页
摘要: 线段树入门题#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!!!!! 阅读(120) 评论(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!!!!! 阅读(208) 评论(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!!!!! 阅读(127) 评论(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!!!!! 阅读(142) 评论(0) 推荐(0)
摘要: 枚举,貌似数据量挺大的,其实不大,就看最深层的tot加了多少次,就可估计出真正的规模//枚举 #include <iostream> #include <stdio.h> #include <algorithm> #define ll long long using namespace std; const int maxn=2000000000; int num[10000]; int main() { ll i1,i2,i3,i4;//注意long long 因为虽然按理说是不会爆int,相乘这个过程可能会溢出 int tot=0; for(i1=1;i 阅读全文
posted @ 2012-12-31 11:47 LJ_COME!!!!! 阅读(135) 评论(0) 推荐(0)
摘要: 直接暴力的话,O(n2),肯定会超时。分解到两个轴上,通过递推求解,O(nlgn)。要理解这种高效求距离的方法。数轴上的某一点到其他点的距离,可通过从小到大或从大到小递推来做。#include <iostream> #include <cstdio> #include <algorithm> #define ll _int64 using namespace std; const int maxn=100010; int x[maxn],y[maxn],rx[maxn],ry[maxn]; ll disx[maxn],disy[maxn]; int n; l 阅读全文
posted @ 2012-12-27 16:05 LJ_COME!!!!! 阅读(126) 评论(0) 推荐(0)
摘要: 字符串匹配。kmp.#include <iostream> #include <stdio.h> #include <string.h> using namespace std; const int maxn=100010; char tran[26],s[maxn]; int next[maxn]; void getv(char * t)//求失配函数 { int i,j;strlen int m=(t); next[0]=-1; i=0;j=-1; while(i<m-1) { if(j==-1||t[i]==t[j]) { j++;i++; if 阅读全文
posted @ 2012-12-27 09:34 LJ_COME!!!!! 阅读(109) 评论(0) 推荐(0)
摘要: 我草!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!靠!以后一定要注意注意判断语句的先后顺序,因为粗心,无数次re,居然调了四个小时,时间啊,心疼#include <iostream> #include <cstdio> #include <queue> using namespace std; const int maxn=200; int dis[maxn*maxn+10],m,n,map[maxn][maxn],loc[maxn*maxn+10],p 阅读全文
posted @ 2012-12-25 18:10 LJ_COME!!!!! 阅读(111) 评论(0) 推荐(0)
摘要: 哈希我太屎啦,以后一定不能再犯写while循环忘了更改循环条件的错误,导致浪费这么长时间来调试#include <iostream> #include <cstdio> using namespace std; const int mod=10000003; const int maxn=4100; struct { int data,sum,next; }node[maxn*maxn]; int head[mod],f[4][maxn],num; void insert(int p) { int k=(p%mod+mod)%mod; int i=head[k]; wh 阅读全文
posted @ 2012-12-24 17:20 LJ_COME!!!!! 阅读(95) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 17 下一页