摘要: 赤裸裸的最小生成树/* * hdu1233/linux.c * Created on: 2011-8-2 * Author : ben */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#define MAXN 105int map[105][105];int N, M;/** * 普里姆求最小生成树,返回最小生成树的权值,返回-1表示图不连通 */int MST_Prim() { int lowcost[MAXN]; int i, j, k, m 阅读全文
posted @ 2011-08-02 22:01 moonbay 阅读(205) 评论(0) 推荐(0) 编辑
摘要: /* * hdu2588/linux.c * Created on: 2011-8-2 * Author : ben */#include <stdio.h>#include <math.h>int phi(int x) { int i, res = x, temp = (int) sqrt(x); for (i = 2; i < temp + 1; i++) { if (x % i == 0) { res = res / i * (i - 1); while (x % i == 0) { x /= i; } } } if (x > 1) { res = r 阅读全文
posted @ 2011-08-02 11:56 moonbay 阅读(203) 评论(0) 推荐(0) 编辑