摘要: 计算几何边的旋转、直线相交的应用代码: 1 #include 2 #include 3 using namespace std; 4 struct node 5 { 6 double x,y; 7 node(double x=0,double y=0):x(x),y(y){} 8 }a,b,c,d,e,f; 9 node operator-(node u,node v){return node(u.x-v.x,u.y-v.y);}10 node operator+(node u,node v){return node(u.x+v.x,u.y+v.y);}11 node o... 阅读全文
posted @ 2013-10-30 21:09 Yours1103 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 计算几何;直线交点; 1 #include 2 using namespace std; 3 4 struct node 5 { 6 double x,y; 7 node(double x=0,double y=0):x(x),y(y){ } 8 }a,b,c,d,e,f,p,q,r; 9 node operator-(node u,node v){return node(u.x-v.x,u.y-v.y);}10 node operator+(node u,node v){return node(u.x+v.x,u.y+v.y);}11 node operator*(node... 阅读全文
posted @ 2013-10-30 16:57 Yours1103 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 简单的AC自动机; 1 #include 2 #include 3 #include 4 #define maxn 150005 5 using namespace std; 6 7 struct node 8 { 9 int cnt; 10 int id; 11 node *a[26],*tail; 12 }no[maxn]; 13 int nonocount; 14 node *newnode() 15 { 16 node *p=no+nonocount++; 17 p->cnt=0; 18 p->id=-1; 19 ... 阅读全文
posted @ 2013-10-30 15:46 Yours1103 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 简单KMP: 1 #include 2 #include 3 #define maxn 1000009 4 using namespace std; 5 6 char s[maxn]; 7 int next[maxn],n; 8 9 void getnext()10 {11 int j=-1,i=0;12 next[0]=-1;13 while(i0&&i%(i-next[i])==0)35 printf("%d %d\n",i,i/(i-next[i]));36 puts("");37 }38 ret... 阅读全文
posted @ 2013-10-30 14:52 Yours1103 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 字典树;不过数据量很大;4000*1000;我用的是传统的方法建树,虽然优化了一下,边插入边统计,不过还是T了;这是我的代码: 1 #include 2 #include 3 #define maxn 4000009 4 using namespace std; 5 int nonocount; 6 long long ans; 7 struct node 8 { 9 int num;10 node *a[62];11 } no[maxn];12 13 node* newnode()14 {15 node *p=no+nonocount++;16 p->num=... 阅读全文
posted @ 2013-10-30 14:26 Yours1103 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 一个简单的字典树上的dp;代码: 1 #include 2 #include 3 #include 4 #define maxn 400000 5 #define mod 20071027 6 using namespace std; 7 priority_queue,greater >q; 8 struct node 9 {10 bool f;11 node *a[26];12 } no[maxn];13 int nonocount;14 int d[maxn];15 bool vis[maxn];16 node *newnode()17 {18 node *p=no... 阅读全文
posted @ 2013-10-30 12:29 Yours1103 阅读(152) 评论(0) 推荐(0) 编辑