上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页
  2012年4月10日
摘要: /* Name: 数学题 Author: Try_86 Date: 10/04/12 20:56*/#include <cstdio>#include <cstring>#include <iostream>using namespace std;int b;char a[1005];int solve() { int ans = 0; for (int i=0; a[i]; ++i) ans = (ans * 10 + a[i] - '0') % b; return ans; }int main() { while (scanf(" 阅读全文
posted @ 2012-04-10 20:58 Try86 阅读(151) 评论(0) 推荐(0)
摘要: /* Name: 并查集 Author: Try_86 Date: 10/04/12 20:11*/#include <cstdio>#include <iostream>using namespace std;const int M = 1000;int p[M], sum;void init(int n) { for (int i=1; i<=n; ++i) p[i] = i; return ;}int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x];}void join(int x, . 阅读全文
posted @ 2012-04-10 20:12 Try86 阅读(179) 评论(0) 推荐(0)
摘要: /* Name: 最小生成树(kruskal) Author: Try_86 Date: 10/04/12 19:51*/#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int M = 700;int p[27], sum;struct edge { int a; int b; int w;}e[M];int cmp(const void *a, const void *b) { return (*(edge *)a).w - (*(edge *) 阅读全文
posted @ 2012-04-10 19:53 Try86 阅读(240) 评论(0) 推荐(0)
摘要: /* Name: 最小生成树(kruskal) Author: Date: 10/04/12 19:17*/#include <math.h>#include <cstdio>#include <iostream>using namespace std;const int M = 5050;int p[101], sum;struct edge { int a; int b; double dis;}e[M];struct point { double x; double y;}po[101];int cmp(const void *a, const v.. 阅读全文
posted @ 2012-04-10 19:20 Try86 阅读(228) 评论(0) 推荐(0)
摘要: /* Name: 最小生成树(kruskal) Author: Try_86 Date: 10/04/12 18:51 Description: 不符合题意所述的距离不加进边集中,然后套用kruskal就可以了 */#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int M = 5050;int p[M], sum;struct edge { int a; int b; double dis;}e[M]; 阅读全文
posted @ 2012-04-10 18:55 Try86 阅读(287) 评论(0) 推荐(0)
摘要: /* Name: hdu1863畅通工程 Author: Try86 Date: 10/04/12 12:43 Description: 最小生成树(kruskal) */#include <cstdio>#include <iostream>using namespace std;const int M = 5050;int p[M], sum; //sum统计顶点个数 struct edge { int a; int b; int w;}e[M];int cmp(const void *a, const void *b) { return (*(edge ... 阅读全文
posted @ 2012-04-10 12:47 Try86 阅读(910) 评论(0) 推荐(0)
  2012年4月9日
摘要: /** 最小生成树,(kruskal) * 本题要点:当两点之间已有路时,把这两点的路长设为0,然后就是套用kruskal了 */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int M = 5050;int p[M];struct edge {//边节点 int a; int b; int w;}e[M];int cmp(const void *a, const void *b) {//按权值从小到大排序 return (*(edge *)a) 阅读全文
posted @ 2012-04-09 22:57 Try86 阅读(568) 评论(0) 推荐(0)
摘要: /** 最小生成树练手题,采用kruskal求解 */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int M = 5050;int p[M];struct edge {//边节点 int a; int b; int w;}e[M];int cmp(const void *a, const void *b) {//按权值从小到大排序 return (*(edge *)a).w - (*(edge * 阅读全文
posted @ 2012-04-09 22:15 Try86 阅读(196) 评论(0) 推荐(0)
摘要: /** hash+数学,很好的题 * 对整数求hash,采用除余法,及线性探测解决冲突 * 注意:devc++中不能定义全局变量count,它和库函数中的函数名同名了 */#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int M = 175447;int counts[M];int result[M];int temp[101];int hashInt(int s) { int k = s % M; if (k < 0) k += M; w 阅读全文
posted @ 2012-04-09 21:05 Try86 阅读(246) 评论(0) 推荐(0)
摘要: /** hash*/#include <cstdio>#include <climits>#include <cstring>#include <iostream>using namespace std;const int M = 1000001;bool hash[M];void init() { for (int i=0; i<M; ++i) hash[i] = false; return ; }int main() { int n, m, maxm; while (scanf("%d%d", &n, &am 阅读全文
posted @ 2012-04-09 19:54 Try86 阅读(220) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页