摘要: 题目:http://www.rqnoj.cn/Problem_15.html 简单的动态规划,AC代码如下: 1 #include<cstdio> 2 #include<iostream> 3 using namespace std; 4 #define Maxsize 102 5 int c[Ma 阅读全文
posted @ 2012-03-30 20:03 Chnwy 阅读(244) 评论(0) 推荐(0) 编辑
摘要: atof(将字串转换成浮点型数)相关函数 atoi,atol,strtod,strtol,strtoul表头文件 #include <stdlib.h>定义函数 double atof(const char *nptr);函数说明 atof()会扫描参数nptr字符串,跳过前面的空格字符,直到遇上数字或正负符号才开始做转换,而再遇到非数字或字符串结束时('\0')才结束转换,并将结果返回。参数nptr字符串可包含正负号、小数点或E(e)来表示指数部分,如123.456或123e-2。返回值 返回转换后的浮点型数。附加说明 atof()与使用strtod(nptr,( 阅读全文
posted @ 2012-03-05 20:33 Chnwy 阅读(201) 评论(0) 推荐(0) 编辑
摘要: DescriptionIn a certain course, you takentests. If you getaiout ofbiquestions correct on testi, your cumulative average is defined to be.Given your test scores and a positive integerk, determine how high you can make your cumulative average if you are allowed to drop anykof your test scores.Suppose 阅读全文
posted @ 2012-02-20 21:48 Chnwy 阅读(239) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe New Year garland consists of N lamps attached to a common wire that hangs down on the ends to which outermost lamps are affixed. The wire sags under the weight of lamp in a particular way: each lamp is hanging at the height that is 1 millimeter lower than the average height of the two 阅读全文
posted @ 2012-02-20 16:14 Chnwy 阅读(307) 评论(0) 推荐(0) 编辑
摘要: DescriptionEvery year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a long, straight river with a rock at the start and another rock at the end, L units away from the start (1 ≤ L ≤ 1,000,0 阅读全文
posted @ 2012-02-19 18:56 Chnwy 阅读(512) 评论(0) 推荐(0) 编辑
摘要: DescriptionInhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has promised to organize the most honest contest ever. It was decided to connect computers for the contestants using a "star" topology - i.e. connect them 阅读全文
posted @ 2012-02-19 15:54 Chnwy 阅读(1017) 评论(0) 推荐(0) 编辑
摘要: DescriptionGiven a connected undirected graph, tell if its minimum spanning tree is unique.Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G is a subgraph of G, say T = (V', E'), with the following properties:1. V' = V.2. T is connected 阅读全文
posted @ 2012-02-19 10:01 Chnwy 阅读(281) 评论(0) 推荐(1) 编辑
摘要: 题目:http://poj.org/problem?id=1029题意: 给你N个硬币,其中只有一个是假的(或轻或重),给你K次测量结果,让你找出那个加硬币。思路: 1.首先我们可以每个硬币一个标记flag,初始值为-2,如果它是真的话,则赋值为0,轻为-1,重为1。 2.对每次的测量结果,我们做如下处理: (1)如果不是‘=’,则假硬币必在其中,我们可将剩余的硬币flag置为0;天平上轻的一端,如果flag=0,则不管, flag=1,则将其置为0,flag=-1,则无法判断;天平重的一端,如果flag=0,不管,如果flag=-1,则将其置为 0,flag=... 阅读全文
posted @ 2012-02-18 11:18 Chnwy 阅读(460) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3522题意:给你一张无向图,让你找出所有生成树中,其最大权值边与最小权值边差最小的一棵树,并输出这个值,如果没有的话 输出0.思路:依次枚举最小边,用Kruskal算法求出最小生成树,记录其差值,并逐个比较,求出最小的。AC代码如下: 1 #include<cstdio> 2 #include<algorithm> 3 #include<iostream> 4 using namespace std; 5 #define MaxN 105 6 #define MaxM 5010 7 #define 阅读全文
posted @ 2012-02-17 19:38 Chnwy 阅读(302) 评论(0) 推荐(0) 编辑
摘要: Problem Description相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,就是2个小岛之间的距离不能小于10米,也不能大于1000米。当然,为了节省资金,只要求实现任意2个小岛之间有路通即可。其中桥的价格为 100元/米。Input输入包括多组数据。输入首先包括一个整数T(T <= 200),代表有T组数据。每组数据首先是一个整 阅读全文
posted @ 2012-02-17 10:11 Chnwy 阅读(196) 评论(0) 推荐(0) 编辑