上一页 1 2 3 4 5 6 ··· 14 下一页
  2012年5月31日
摘要: 1 #include <cstdio> 2 #include <cstdlib> 3 #include <iostream> 4 5 using namespace std; 6 7 const int N = 50005; 8 9 //旋转卡壳(变化)求凸包直径O(n)10 struct point {11 int x, y;12 }p[N];13 14 int dis(point A, point B) {15 return (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y);16 }17 18 i 阅读全文
posted @ 2012-05-31 07:41 Try86 阅读(217) 评论(0) 推荐(0)
  2012年5月30日
摘要: 1 /* 2 * 一般增广路算法--Ford_Fulkerson算法(标号法) 3 */ 4 /* 5 建图:将顾客看作除源点和汇点以外的节点,源点和每个猪圈的第一个顾客连边,边的权是开始时猪 6 圈中猪的数目,若源点和某个节点之间有重边,则将权合并,顾客j紧跟在顾客i之后打开某个猪圈, 7 则边<i,j>的权是+∞,每个顾客和汇之间连边,边的权是顾客所希望购买的猪的数目。 8 */ 9 10 #include <cstdio>11 #include <cstring>12 #include <iostream>13 14 using names 阅读全文
posted @ 2012-05-30 22:25 Try86 阅读(783) 评论(0) 推荐(0)
  2012年5月16日
摘要: 1 /* 2 * 归并排序求逆序对 3 */ 4 5 #include <cstdio> 6 #include <iostream> 7 8 using namespace std; 9 10 const int N = 500005;11 12 long long ans;13 int a[N], b[N];14 15 void mergeSort(int left, int right) {16 int i, j, k, mid;17 if (left < right) {18 mid = (left + right) >> 1;19 ... 阅读全文
posted @ 2012-05-16 20:51 Try86 阅读(154) 评论(0) 推荐(0)
摘要: 1 /* 2 * 0/1背包 3 */ 4 #include <cstdio> 5 #include <cstring> 6 #include <iostream> 7 8 using namespace std; 9 10 const int N = 105;11 const int M = 1005;12 13 int f[M];14 struct pack {15 int cost;16 int value;17 }p[N];18 19 void ZeroOnePack(int n, int cost, int value) {20 for (int 阅读全文
posted @ 2012-05-16 20:43 Try86 阅读(144) 评论(0) 推荐(0)
摘要: 1 /* 2 * 0/1背包 3 */ 4 #include <cstdio> 5 #include <cstring> 6 #include <iostream> 7 8 using namespace std; 9 10 const int M = 30;11 const int N = 30005;12 13 int f[N];14 struct pack {15 int cost;16 int value;17 }p[M];18 19 void ZeroOnePack(int n, int cost, int value) {20 for (int 阅读全文
posted @ 2012-05-16 20:33 Try86 阅读(166) 评论(0) 推荐(0)
  2012年5月14日
摘要: 1 /* 2 * 归并排序求逆序对 3 */ 4 5 #include <cstdio> 6 #include <iostream> 7 8 using namespace std; 9 10 const int N = 20005;11 12 long long ans;13 int a[N], b[N];14 15 void mergeSort(int left, int right) {16 int i, j, k, mid;17 if (left < right) {18 mid = (left + right) >> 1;19 ... 阅读全文
posted @ 2012-05-14 22:51 Try86 阅读(158) 评论(0) 推荐(0)
摘要: 1 /* 2 * 简单BFS 3 */ 4 5 #include <cstdio> 6 #include <cstring> 7 #include <iostream> 8 9 using namespace std;10 11 const int N = 2005;12 13 int map[N][N];14 bool vis[N][N];15 struct node {16 int x;17 int y;18 int c;19 }Q[N*N], s, e;20 int front, rear;21 int dir[4][2] = {{0, 1}, {.. 阅读全文
posted @ 2012-05-14 12:40 Try86 阅读(329) 评论(0) 推荐(0)
  2012年5月13日
摘要: #include <cstdio>#include <iostream>using namespace std;int ans;void dfs(int n) { for (int i=1; i<=n/2; ++i) { ++ans; dfs(i); }}int main() { int n; while (scanf("%d", &n) != EOF) { ans = 1; dfs(n); printf ("%d\n", ans); } return 0;} 阅读全文
posted @ 2012-05-13 13:54 Try86 阅读(161) 评论(0) 推荐(0)
摘要: #include <cstdio>#include <cstring>#include <iostream>using namespace std;const int N = 1005;char map[N][N], vis[N][N];struct node { int x; int y; int c;}Q[N*N], s, e;int front, rear;int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};int BFS(int n) { node first, next; front = rear 阅读全文
posted @ 2012-05-13 13:33 Try86 阅读(168) 评论(0) 推荐(0)
摘要: #include <cmath>#include <cstdio>#include <iostream>using namespace std;double dis(double x1, double y1, double x2, double y2) { return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}int main() { double x1, y1, r1, x2, y2, r2; while (scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, 阅读全文
posted @ 2012-05-13 08:23 Try86 阅读(160) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 14 下一页