2012年4月16日
摘要:
View Code /* Name: 拓扑排序,多次拓扑 Copyright: Author: Try86 Date: 16/04/12 21:36 Description: */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int N = 27;bool ch[N];char ans[N]; //存拓扑序 int inDeg[N]; //入度数 struct node { int v; node
阅读全文
posted @ 2012-04-16 22:06
Try86
阅读(144)
推荐(0)
摘要:
View Code /* Name: 日期相关 Copyright: Author: Try86 Date: 15/04/12 23:32 Description: */#include <cstdio>#include <iostream>using namespace std;bool isLeap(int year) { if (year%400==0 || year%4==0&&year%100!=0) return true; return false;} int main() { int t; scanf ("%d", &
阅读全文
posted @ 2012-04-16 07:34
Try86
阅读(239)
推荐(0)
2012年4月15日
摘要:
View Code /* Name: 简单数学 Copyright: Author: Try86 Date: 15/04/12 22:45 Description: */#include <cstdio>#include <iostream>using namespace std;int main() { double len; while (scanf("%lf", &len), len!=0.00) { double sum = 0; int i; for (i=2; sum<len; ++i) sum += 1.0/i;...
阅读全文
posted @ 2012-04-15 22:47
Try86
阅读(201)
推荐(0)
摘要:
View Code /* Name: 拓扑排序,判断有向图是否存在回路及自环,并统计每个顶点的前驱点数 Copyright: Author: Try86 Date: 15/04/12 22:25 Description: */#include <queue>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int N = 10005;int sum, flag;int counts[N];s
阅读全文
posted @ 2012-04-15 22:38
Try86
阅读(752)
推荐(0)
摘要:
View Code /* Name: 利用拓扑排序过程判断有向图是否有回路及自环 Copyright: Author: Try86 Date: 15/04/12 21:15 Description: */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int N = 105;int color[N], flag;struct node { int v; node *next; node(int vv,
阅读全文
posted @ 2012-04-15 21:31
Try86
阅读(331)
推荐(0)
摘要:
View Code /* Name: 最小生成树(kruskal) Copyright: Author: Try86 Date: 15/04/12 08:01 Description: */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 10005;const int M = 50005;int p[N], sum;struct edge { int u; int v; int w;}e[M];int cmp(const void
阅读全文
posted @ 2012-04-15 08:10
Try86
阅读(199)
推荐(0)
摘要:
/* Name: 判断无向图是否连通+统计顶点的度数 Copyright: Author: Try86 Date: 14/04/12 23:02 Description: 邻接链表存图 */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int N = 105;int deg[N]; //统计顶点的度数 bool map[N][N], color[N];struct node { int v; nod
阅读全文
posted @ 2012-04-15 07:36
Try86
阅读(534)
推荐(0)
2012年4月14日
摘要:
/* Name: Havel-Hakiwi定理的应用 Copyright: Author: Try86 Date: 13/04/12 23:16 Description: */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;int map[15][15], flag;struct node { int deg; //顶点度数 int ver; //顶点编号 }d[15];int cmp(const void *a
阅读全文
posted @ 2012-04-14 07:42
Try86
阅读(229)
推荐(0)
2012年4月12日
摘要:
/* Name: 位运算应用 Copyright: Author: Try_86 Date: 12/04/12 22:24 Description: */#include <cstdio>#include <iostream>using namespace std;int main() { int a; while (scanf("%d", &a), a) printf ("%d\n", a&(a^(a-1))); return 0;}
阅读全文
posted @ 2012-04-12 22:27
Try86
阅读(153)
推荐(0)
摘要:
/* Name: 最短路(dijkstra邻接矩阵)+hash判重并统计顶点数+二分查找返回顶点位置 Copyright: Author: Try_86 Date: 12/04/12 20:57 Description: 注意:起始点和终点不在给出的路线中的情况!!! */#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>using namespace std;const int S = 163; const int N = 155;const int
阅读全文
posted @ 2012-04-12 21:15
Try86
阅读(196)
推荐(0)