上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 43 下一页
摘要: 最小生成树和次小生成树定义:生成树:图G的生成树包含原图中的全部顶点n,和n-1条边.最小生成树就是所有生成树中边权和最小的.2 那么如何求最小生成树呢?介绍两种基于贪心的算法:1.prim算法 设图G =(V,E),其生成树的顶点集合为U。 ①、把v0放入U。 ②、在所有u∈U,v∈V-U的边(u,v)∈E中找一条最小权值的边,加入生成树。 ③、把②找到的边的v加入U集合。如果U集合已有n个元素,则结束,否则继续执行②。2.kruskal算法 首先将所有边按边权排序,然后按照边权从小到大依次处理.这里要用到并查集的思想,假设已有点集U,现在正在处理边i->j,如果i,j已在U中则... 阅读全文
posted @ 2012-07-31 17:47 可笑痴狂 阅读(4797) 评论(0) 推荐(2)
摘要: 最长回文子串时间限制:1000 ms | 内存限制:65535 KB难度:4描述输入一个字符串,求出其中最长的回文子串。子串的含义是:在原串连续出现的字符串片段。回文的含义是:正着看和倒着看是相同的,如abba和abbebba。在判断是要求忽略所有的标点和空格,且忽略大小写,但输出时按原样输出(首尾不要输出多余的字符串)。输入字符串长度大于等于1小于等于5000,且单独占一行(如果有多组答案,输出第一组)。输入输入一个测试数据n(1<=n<=10);随后有n行,每行有一个字符串。输出输出所要求的回文子串。样例输入1Confuciuss say:Madam,I'm Adam. 阅读全文
posted @ 2012-07-30 16:50 可笑痴狂 阅读(2529) 评论(0) 推荐(0)
摘要: 题目连接:http://poj.grids.cn/practice/2972/ 1 /* 功能Function Description: 2 开发环境Environment: DEV C++ 4.9.9.1 3 技术特点Technique: 4 版本Version: 5 作者Author: 可笑痴狂 6 日期Date: 20120730 7 备注Notes: 8 描述 9 6*9 = 42 对于十进制来说是错误的,但是对于13进制来说是正... 阅读全文
posted @ 2012-07-30 16:31 可笑痴狂 阅读(491) 评论(0) 推荐(0)
摘要: 1 /* 功能Function Description: 2 开发环境Environment: DEV C++ 4.9.9.1 3 技术特点Technique: 4 版本Version: 5 作者Author: 可笑痴狂 6 日期Date: 20120730 7 备注Notes: 8 SubmitStatisticsClarifyTime Limit: 1000msMemory Limit: 65536kB 9 Description10 ... 阅读全文
posted @ 2012-07-30 16:06 可笑痴狂 阅读(307) 评论(0) 推荐(0)
摘要: Catch That CowTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 30924Accepted: 9536DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100, 阅读全文
posted @ 2012-07-30 09:22 可笑痴狂 阅读(2696) 评论(1) 推荐(0)
摘要: I Love This GameTime Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3528Accepted Submission(s): 1211Problem DescriptionDo you like playing basketball ? If you are , you may know the NBA Skills Challenge . It is the content of the basketball skills . It 阅读全文
posted @ 2012-07-27 15:28 可笑痴狂 阅读(228) 评论(0) 推荐(0)
摘要: The PeanutsTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 6500Accepted: 2736DescriptionMr. Robinson and his pet monkey Dodo love peanuts very much. One day while they were having a walk on a country road, Dodo found a sign by the road, pasted with a small piece of paper, saying "Free 阅读全文
posted @ 2012-07-27 11:47 可笑痴狂 阅读(623) 评论(0) 推荐(0)
摘要: 士兵杀敌(二)时间限制:1000 ms | 内存限制:65535 KB难度:5描述南将军手下有N个士兵,分别编号1到N,这些士兵的杀敌数都是已知的。小工是南将军手下的军师,南将军经常想知道第m号到第n号士兵的总杀敌数,请你帮助小工来回答南将军吧。南将军的某次询问之后士兵i可能又杀敌q人,之后南将军再询问的时候,需要考虑到新增的杀敌数。输入只有一组测试数据第一行是两个整数N,M,其中N表示士兵的个数(1<N<1000000),M表示指令的条数。(1<M<100000)随后的一行是N个整数,ai表示第i号士兵杀敌数目。(0<=ai<=100)随后的M行每行是一条 阅读全文
posted @ 2012-07-26 18:59 可笑痴狂 阅读(364) 评论(0) 推荐(0)
摘要: CalendarTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 8936Accepted: 3354DescriptionA calendar is a system for measuring time, from hours and minutes, to months and days, and finally to years and centuries. The terms of hour, day, month, year and century are all units of time measurements 阅读全文
posted @ 2012-07-26 17:46 可笑痴狂 阅读(988) 评论(2) 推荐(0)
摘要: Counterfeit DollarTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 33094Accepted: 10495DescriptionSally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver dollars; one coin is counterfeit even though its color and size make it indistinguishable from 阅读全文
posted @ 2012-07-26 16:10 可笑痴狂 阅读(2226) 评论(0) 推荐(0)
上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 43 下一页