上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页
摘要: 叉积+二分通过叉积来判断点在线段的某侧,找到在点右侧的最左边的边,即可判断点在第几个格子内,可以通过二分来优化查询速度#include <iostream> #include <algorithm> #include <cstdio> using namespace std; const int maxn=1000+10; int n,m,x1,y1,x2,y2; struct segment { int loc1,loc2; }; segment s[maxn]; int c[maxn],res[maxn]; bool cmp(segment a,segm 阅读全文
posted @ 2013-02-28 19:55 LJ_COME!!!!! 阅读(124) 评论(0) 推荐(0)
摘要: dfs+奇偶剪枝,关键在于奇偶剪枝的应用#include <iostream> #include <stdio.h> using namespace std; char s[10][10]; int vis[10][10]; int d[4][2]={{0,1},{0,-1},{1,0},{-1,0}}; int fx,fy; int n,m,t; int flag; void dfs(int sx,int sy,int step) { int i; if((t-step)%2!=(sx+sy+fx+fy)%2) return;//奇偶性剪枝 if(step==t) . 阅读全文
posted @ 2013-02-26 20:22 LJ_COME!!!!! 阅读(126) 评论(0) 推荐(0)
摘要: 递推,找规律#include <iostream> #include <cstdio> using namespace std; int count[510]; int main() { count[1]=1; int i,j; for(i=2;i<=500;i++) { int t=count[i-1]; for(j=1;j<=i;j++) t=t+i+1-j; for(j=1;i-j>=j;j++) t=t+i-j+1-j; count[i]=t; } int n; while(cin>>n) cout<<count[n]& 阅读全文
posted @ 2013-02-25 19:27 LJ_COME!!!!! 阅读(128) 评论(0) 推荐(0)
摘要: 数论 模#include <iostream> #include <cstdio> #include <string.h> using namespace std; const int maxn=110; char n[maxn],m[maxn]; int int_m; int len1,len2; int judge() { if(len1>len2) return 1; char tn[maxn],tm[maxn]; int i,j; for(i=len1-1,j=0;i>=0;i--,j++) tn[j]=n[i]; tn[j]=' 阅读全文
posted @ 2013-02-03 15:39 LJ_COME!!!!! 阅读(124) 评论(0) 推荐(0)
摘要: dp水题,不解释#include <iostream> #include <cstdio> using namespace std; const int maxn=1000+10; int v[maxn]; long long sumv[maxn]; int main() { int n; while(~scanf("%d",&n)&&n) { int i,j; for(i=1;i<=n;i++) scanf("%d",&v[i]); memset(sumv,0,sizeof(sumv)); 阅读全文
posted @ 2013-02-02 16:28 LJ_COME!!!!! 阅读(111) 评论(0) 推荐(0)
摘要: 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!!!!! 阅读(129) 评论(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!!!!! 阅读(124) 评论(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!!!!! 阅读(128) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页