上一页 1 2 3 4 5 6 ··· 15 下一页

2012年4月5日

priority_queue的用法

摘要: 以下转载,请看原文:http://www.cnblogs.com/flyoung2008/articles/2136485.html,priority_queue调用 STL里面的 make_heap(), pop_heap(), push_heap() 算法实现,也算是堆的另外一种形式。先写一个用 STL 里面堆算法实现的与真正的STL里面的 priority_queue用法相似的priority_queue, 以加深对 priority_queue 的理解?#include <iostream>#include <algorithm>#include <vec 阅读全文

posted @ 2012-04-05 19:37 Goal 阅读(250) 评论(0) 推荐(0) 编辑

2012年4月3日

hdu 3001 状态压缩

摘要: 转载:http://hi.baidu.com/the_one1989/blog/item/002aeb862327be83f603a618.htmlhttp://acm.hdu.edu.cn/showproblem.php?pid=3001 很经典的TSP问题,但是题目又有改变,每个旅游地可以走两遍,故进行扩展2状态的状态压缩DP伸展为3状态的状态压缩问题。0表示没去过此点,1 表示去过一次,2表示去过两次,状态转移方程基本和以前一样dp[i][j]=min(dp[i][k]+map[k][j]),状态压缩表示要稍微耐心 点。附上代码#include"iostream"#i 阅读全文

posted @ 2012-04-03 17:05 Goal 阅读(349) 评论(0) 推荐(0) 编辑

dp Sum of Digits

摘要: Sum of DigitsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 181Accepted Submission(s): 53Problem DescriptionPetka thought of a positive integer n and reported to Chapayev the sum of its digits and the sum of its squared digits. Chapayev scratched 阅读全文

posted @ 2012-04-03 17:03 Goal 阅读(226) 评论(0) 推荐(0) 编辑

2012年4月2日

poj 并查集

摘要: Navigation NightmareTime Limit: 2000MSMemory Limit: 30000KTotal Submissions: 2559Accepted: 1087Case Time Limit: 1000MSDescriptionFarmer John's pastoral neighborhood has N farms (2 <= N <= 40,000), usually numbered/labeled 1..N. A series of M (1 <= M < 40,000) vertical and horizontal 阅读全文

posted @ 2012-04-02 21:02 Goal 阅读(196) 评论(0) 推荐(0) 编辑

bnu dp

摘要: gabrielusDescriptiongabrielus是个斐波那契数迷。他是如此的酷爱这个数列,因此他想知道很多关于这个数列的东西,比方说第N个斐波那契数是多少啊、前N项的和是多少 啊如何用若干个斐波那契数的和表示一个自然数啊之类之类的。今天他希望知道的是:他想用第1个、第2个…第N个斐波那契数构成一个长度为P的序列,每个斐 波那契数可以使用任意多次,但至少要使用一次,并且序列中任意两个相同的斐波那契数之间至少要隔着M个数,gabrielus希望知道满足条件的序列组成 方法有多少种。记fib[i]表示第i个斐波那契数,fib[0]=fib[1]=1, fib[i]=fib[i-1]+fib 阅读全文

posted @ 2012-04-02 11:28 Goal 阅读(287) 评论(0) 推荐(0) 编辑

2012年4月1日

BNU Minimum Spanning Tree

摘要: Minimum Spanning TreeDescription某无向图上有N个点M条边,任意两点之间的路径数不超过1。从某一点经过一条边到达另一个点的花费为1。某人将被扔到图中某个点上,他希望知道在最好情况下,要访问至少K个不同的点的最少花费是多少,他起始被扔到的那个点也算他访问的点。Input每组输入的第一行为两个数N,M(1≤N≤10^5,0≤M≤10^5)。接下来的M行每行两个数X,Y(1≤X,Y≤N)表示X和Y之间有一条无向边。接下来的一行为一个数Q表示询问个数(1≤Q≤10^5)。接下来的Q行每行一个数K(1≤K≤10^5)。Output对于每个询问,输出一个数表示最小花费。若无论 阅读全文

posted @ 2012-04-01 19:48 Goal 阅读(160) 评论(0) 推荐(0) 编辑

哈希 A+B Problem

摘要: A+B ProblemCase Time Limit: 1000msMemory Limit: 65536KBPrev Submit Status Discuss NextDescription给定三个由'0','1','?'构成的字符串s0,s1,s2,其中'?'表示该位可能是0也可能是1。如果有三个数A,B,C满足这三个数的二进制依 次是这三个字符串,且有A+B=C则称有序三元组<A,B,C>是这三个字符串的一组解。例如<0,2,2>和< 1,2,3>都是{"0?",&q 阅读全文

posted @ 2012-04-01 16:38 Goal 阅读(145) 评论(0) 推荐(0) 编辑

2012年3月31日

背包 Four Gate Push

摘要: Four Gate PushTime Limit: 1 SecMemory Limit: 128 MBSubmit: 101Solved: 59[Submit][Status][Web Board]DescriptionYou are working hard on your Protoss builds in StarCraft II, especially the 4 Gate Push. You've come upon a tough problem, however, which is how to determine the distribution of zealots, 阅读全文

posted @ 2012-03-31 16:34 Goal 阅读(205) 评论(0) 推荐(0) 编辑

dp tree count

摘要: Tree CountTime Limit: 5 SecMemory Limit: 128 MBSubmit: 29Solved: 14[Submit][Status][Web Board]DescriptionOur superhero Carry Adder has uncovered the secret method that the evil Head Crash uses to generate the entrance code to his fortress in Oakland. The code is always the number of distinct binary 阅读全文

posted @ 2012-03-31 15:39 Goal 阅读(253) 评论(0) 推荐(0) 编辑

组合数学

摘要: Non-Decreasing DigitTime Limit: 2 SecMemory Limit: 128 MBSubmit: 183Solved: 48[Submit][Status][Web Board]DescriptionA number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit. For example, the four-digit number 1234 is compo 阅读全文

posted @ 2012-03-31 15:33 Goal 阅读(168) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 15 下一页

导航