02 2013 档案

摘要:叉积+二分通过叉积来判断点在线段的某侧,找到在点右侧的最左边的边,即可判断点在第几个格子内,可以通过二分来优化查询速度#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!!!!! 阅读(125) 评论(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!!!!! 阅读(127) 评论(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!!!!! 阅读(130) 评论(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!!!!! 阅读(113) 评论(0) 推荐(0)