摘要: http://blog.csdn.net/fengart/article/details/2480774 阅读全文
posted @ 2012-12-15 16:27 zx雄 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 点积:a . b = x1x2 + y1y2 叉积 a x b = x1y2 - x2y1直线上 : 叉积等于零表示两条直线平行/重合。线段上 : 阅读全文
posted @ 2012-12-15 10:26 zx雄 阅读(172) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3006 1 #include <iostream> 2 using namespace std; 3 const int MAX = 0x0007fff; 4 int used[MAX] = {0}; 5 int main(){ 6 int n,m; 7 while(cin>>n>>m){ 8 m = 1<<m; 9 memset(used,0,sizeof(used));10 int i;11 for(i=0;i<n;i++){... 阅读全文
posted @ 2012-12-05 21:05 zx雄 阅读(216) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1892树状数组拓展到二维 1 #include <iostream> 2 using namespace std; 3 const int MAX = 1000 + 10; 4 int a[MAX][MAX]; 5 int c[MAX][MAX]; 6 int LowBit(int lb){ 7 return lb & (-lb); 8 } 9 void Updata(int x,int y,int value){ 10 int i,j; 11 for(i=x;i<M... 阅读全文
posted @ 2012-12-02 16:12 zx雄 阅读(281) 评论(0) 推荐(0) 编辑
摘要: next_permutation()作用:找下一个全排列数0 1 2 从0 1 2 变成 0 2 10 2 1 重新变为 0 1 2 时会返回01 0 21 2 02 0 12 1 0next_permutation(头指针,尾指针);prev_permutation()作用:找上一个全排列数0 1 2 从02 1变成 0 1 20 2 1 重新变为 0 1 2 时会返回01 0 21 2 02 0 12 1 0prev_permutation(头指针,尾指针); 阅读全文
posted @ 2012-12-01 11:03 zx雄 阅读(148) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1532题意:找到从起点到终点的最大流. BFS()---- 找到一条增广路 GetFlow()---- 找到该增广路的流量,即流量最小的边,减去流量,再在增广路的个边上补反边 1 #include <iostream> 2 #include <queue> 3 using namespace std; 4 const int MAX = 200 + 10; 5 const int INF = 0x3fffffff; 6 7 bool used[MAX]; 8 int front[MAX 阅读全文
posted @ 2012-11-30 19:21 zx雄 阅读(235) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4031用了树状数组的区间更新 单点查找(一般为单点更新 区间查找)例如 区间(2,4)加1则Updata(2,1) Updata(4+1,-1)实现了更新(2,4)的值而不改变其他值求Sum时即可得到某一点的值View Code #include <iostream>using namespace std;const int MAX = 20000 + 100;int C[MAX];int N;struct Node{ int l; int r;};int LowBit(int x){ re... 阅读全文
posted @ 2012-11-10 18:30 zx雄 阅读(2490) 评论(0) 推荐(0) 编辑
摘要: 坑坑爹爹连改带抄的把代码坑了出来View Code 1 #include <stdio.h> 2 #include <malloc.h> 3 #include <queue> 4 #include <Windows.h> 5 const int MAX = 10; 6 typedef int KeyType ; 7 typedef struct Node{ 8 int keynum;//关键字数目 9 KeyType key[MAX];//关键字 由1开始 10 Node *parent; 11 Node *child[MAX]; 12 }... 阅读全文
posted @ 2012-11-07 18:31 zx雄 阅读(301) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1541View Code 1 #include <iostream> 2 #include <queue> 3 using namespace std; 4 const int MAX = 32000 + 10; 5 //const int MAXN = 15000 + 10; 6 int C[MAX]; 7 int Level[MAX]; 8 int n; 9 int LowBit(int x)10 {11 return x & (-x);12 }13 void Update 阅读全文
posted @ 2012-11-07 17:19 zx雄 阅读(306) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1166//View Code 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 const int MAX = 50000 + 10; 5 int C[MAX]; 6 int n; 7 int LowBit(int x) 8 { 9 return (x&(-x));10 }11 void Update(int num,int k)12 {13 while(num <= n)14 {15 . 阅读全文
posted @ 2012-11-03 17:30 zx雄 阅读(172) 评论(0) 推荐(0) 编辑