hdu 1305 Immediate Decodability

摘要: An encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in binary, that no two codes within a set of codes are the same, that each code has at least one bit and no mor 阅读全文
posted @ 2012-03-28 17:48 江财小子 阅读(204) 评论(0) 推荐(0) 编辑

二叉搜索树(HDU3791)

摘要: 判断两序列是否为同一二叉搜索树序列Input开始一个数n,(1#include inta[1024],b[1024];voidcta(charc,inti)//这个和下面可以合并一个,用指针传递数组{ if(a[i]==0) {a[i]=c;return;} if(a[i]>c) cta(c,ic) ctb(c,im2?m2:m1;//递归回程,判断树是否一样}intmain(){inti,n; charc[13],s[13]; while(scanf("%d",&n),n) { memset(a,0,sizeof(a)); scanf("%s&qu 阅读全文
posted @ 2012-03-28 17:46 江财小子 阅读(1231) 评论(0) 推荐(0) 编辑

HDU 1045 Fire Net(DFS)

摘要: Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall.A blockhouse is a small castle that has four openings through which to shoot. The four openings are facing North, East, South, and West 阅读全文
posted @ 2012-03-28 17:43 江财小子 阅读(166) 评论(0) 推荐(0) 编辑

HDU 1010 Tempter of the Bone(DFS)

摘要: The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone was a trap, and he tried desperately to get out of this maze.The maze was a rectangle with sizes N b 阅读全文
posted @ 2012-03-28 17:40 江财小子 阅读(213) 评论(0) 推荐(0) 编辑

HDU 2084 数塔

摘要: 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗?Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N... 阅读全文
posted @ 2012-03-28 17:39 江财小子 阅读(132) 评论(0) 推荐(0) 编辑

HDU 1003 Max Sum

摘要: Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in th... 阅读全文
posted @ 2012-03-28 17:38 江财小子 阅读(165) 评论(0) 推荐(0) 编辑

HDU 2037 今年暑假不AC

摘要: 今年暑假不AC?”“是的。”“那你干什么呢?”“看世界杯呀,笨蛋!”“@#$%^&*%...”确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级女生,以及王小丫的《开心辞典》等等,假设你已经知道了所有你喜欢看的电视节目的转播时间表,你会合理安排吗?(目标是能看尽量多的完整节目)Input输入数据包含多个测试实例,每个测试实例的第一行只有一个整数n(n<=100),表示你喜欢看的节目的总数,然后是n行 阅读全文
posted @ 2012-03-28 17:36 江财小子 阅读(134) 评论(0) 推荐(0) 编辑

HDU 1009 FatMouse' Trade

摘要: FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMouse does not have to trade for all the JavaBeans in 阅读全文
posted @ 2012-03-28 17:35 江财小子 阅读(123) 评论(0) 推荐(0) 编辑

HDU 1425 sort

摘要: 给你n个整数,请按从大到小的顺序输出其中前m大的数。Input每组测试数据有两行,第一行有两个数n,m(0//比用快排做快了200Ms#include #include inta[1000001];intmain(){ //freopen("in.txt","r",stdin); intn,m,k; while(scanf("%d%d",&n,&m)!=EOF) { memset(a,0,sizeof(a)); while(n--) { scanf("%d",&k); a[k+500000] 阅读全文
posted @ 2012-03-28 17:34 江财小子 阅读(156) 评论(0) 推荐(0) 编辑

hdu 3784 继续xxx定律

摘要: 当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数,5,8,4,2称为覆盖数。现在输入n个数字a[i],根据关键数与覆盖数的理论,我们只需要验证其中部分数就可以确定所有数满足xxx定律,输出输入的n个数中的关键数。如果其中有多个关键数的话按照其输入顺序的逆序输出。Input输入数据包含多个用例,每个用例首先包含一个整数n,然后接下来一行有n个整数a[i],其中:1#include #include using namespacestd;boolh[200000];intmain(){ intn,m,i,k,a[503],b[503]; while(s 阅读全文
posted @ 2012-03-28 17:33 江财小子 阅读(260) 评论(0) 推荐(0) 编辑