Friend Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2207 Accepted Submission(s): 1108 Problem Description Friend number are defined recursively as follows. (1) numbers 1 and 2 are friend…
并查集 英文:Disjoint Set,即“不相交集合” 将编号分别为1…N的N个对象划分为不相交集合, 在每个集合中,选择其中某个元素代表所在集合. 常见两种操作: n 合并两个集合 n 查找某元素属于哪个集合 并查集实现的程序代码: int set[MAXN],rank[MAXN]; //set[i]=k表示i的父节点是k,rank[]存储树的深度. int FindSet(int x) { if(set[x]!=x) set[x]=FindSet(set[x])…
Problem Description The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up o…
[HDOJ 2255]奔小康赚大钱(KM算法) 奔小康赚大钱 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6051 Accepted Submission(s): 2667 Problem Description 传说在遥远的地方有一个很富裕的村落,有一天,村长决定进行制度改革:又一次分配房子. 这但是一件大事,关系到人民的住…
Problem Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says. "The second problem is, given an positive integer N, we define an equation like this: N=a[1]+a[2]+a[3]+-+a[m];…
Problem Description Computer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the form seed(x+1) = [seed(x) + STEP] % MOD where '%' is the modulus operator. Such a function will generate pseudo-…
题目: Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况.由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视.中央情报局要研究敌人究竟演习什么战术,所以Tidy要随时向Derek汇报某一段连续的工兵营地一共…