摘要: 终于做到第三章了。3.1开始是最小生成树的介绍文章,给出了Prim算法的伪代码(写的挺好)。之后有6个题目,其实只有第一个题目和最小生成树有关- -。Agri-Net:裸最小生成树。 1 # include 2 3 4 int ans, n, INF = 0x0f0f0f0f ; 5 int g[110][110] ; 6 int intree[110], d[110] ; 7 8 9 void mst()10 {11 int ts, pos, i, treecost ;12 ans = -1 ;13 for (i = 0 ; i d[i]) pos = i... 阅读全文
posted @ 2013-07-04 19:56 Seraph2012 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1264题意:给许多矩形,求面积并。坐标是0到100内的整数。mark:把矩形覆盖的区域赋值为1。。。代码: 1 # include 2 3 4 int g[110][110] ; 5 6 7 int main () 8 { 9 int a, b, c, d, t, i, j, ans ;10 while (~scanf ("%d%d%d%d", &a, &b, &c, &d))11 {12 if (a == -1 && b == -1 阅读全文
posted @ 2013-07-04 08:16 Seraph2012 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1727题意:给一个数字,输出它的英文。。。细节比较多,小心点就不容易出错。代码: 1 # include 2 3 4 char tab[][20] = { 5 "zero", "one", "two", "three", "four", "five", 6 "six", "seven", "eight", "nine 阅读全文
posted @ 2013-07-04 04:23 Seraph2012 阅读(211) 评论(0) 推荐(0) 编辑
摘要: mark:题意很简单。。。输出小数形式,要标记循环节。不难就是写起来挺麻烦,开辟一个数组来标记余数是否出现过可以找到循环节。而且要记录循环节起始出现的位置。写的比较恶心。还有76个字符一行,要注意换行。最长的是1/9991,循环周期是1632位。。。代码写的比较恶心。。。代码:# include # include int vis[1000010], ans[1000010] ;char str[1000000] ;int main (){ int cnt, cc, n, d, i; freopen ("fracdec.in", "r", stdin) 阅读全文
posted @ 2013-07-04 02:15 Seraph2012 阅读(333) 评论(0) 推荐(1) 编辑
摘要: mark:就是个最短路。。。错了2次,一次是题目没读清楚,一次是自己犯2。。。代码: 1 # include 2 3 4 int graph[210][210] ; 5 int INF = 0x0f0f0f0f ; 6 7 8 int min(int a, int b){return a<b?a:b;} 9 10 11 int main ()12 {13 char ch1, ch2 ;14 int num, p, pos, i, j, k ;15 16 freopen ("comehome.in", "r", stdin) ;17 freope.. 阅读全文
posted @ 2013-07-04 01:41 Seraph2012 阅读(223) 评论(0) 推荐(0) 编辑
摘要: mark:题意不是很好懂的样子。先用floyd求最短路,再枚举两个块的每条边。。。细节要注意,另外要用double。。。2A,图论我果然很弱啊。代码: 1 # include 2 # include 3 # include 4 5 6 int n ; 7 int x[200], y[200] ; 8 double dp[200], g[200][200], INF = 1e9, ans ; 9 char gra[200][200] ;10 11 12 double dist(double a, double b, double c, double d){return sqrt((a-... 阅读全文
posted @ 2013-07-04 01:05 Seraph2012 阅读(248) 评论(0) 推荐(0) 编辑