上一页 1 2 3 4 5 6 7 ··· 11 下一页
摘要: Problem BThe Twin TowersInput:standard inputOutput:standard outputOnce upon a time, in an ancient Empire, there were two towers of dissimilar shapes in two different cities. The towers were built by putting circular tiles one upon another. Each of the tiles was of the same height and had integral ra 阅读全文
posted @ 2014-02-17 21:50 ~~Snail~~ 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 范围最小值问题(Range Minimum Query,RMQ)。给出一个长度为n的数组A1,A2,…,An,设计一个数据结构,支持查询操作Query(L,R):计算min{AL,AL+1,…,AR} 对于这种数组中元素不会进行更新的情形,最常用的是Tarjan的Sparse-Table算法,它用O(nlogn)的时间进行预处理,之后每次查询只要O(1)的时间,而且常数很小 设d[i][j]表示从 i 开始,长度为2^j的一段元素中的最小值,则可以得到递推关系:d[i][j] = min { d[i][j-1] , d[i+2^(j-1)][j-1] } 预处理代码如下: 1 #in... 阅读全文
posted @ 2014-02-07 12:29 ~~Snail~~ 阅读(1027) 评论(0) 推荐(0) 编辑
摘要: 2007/2008 ACM International Collegiate Programming ContestUniversity of Ulm Local ContestProblem F: Frequent valuesYou are given a sequence ofnintegersa1, a2, ... , anin non-decreasing order. In addition to that, you are given several queries consisting of indicesiandj(1 ≤ i ≤ j ≤ n). For each query 阅读全文
posted @ 2014-02-07 12:10 ~~Snail~~ 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #define MAX 100000 3 4 //数组c为树状数组,MAX为数状数组大小 5 int c[MAX]; 6 7 //lowbit函数 8 int lowbit(int x) 9 {10 return x&(-x);11 }12 13 //树状数组求和函数,求c[1]+c[2]+…+c[x]14 //注意如果题目中可能出现x=0的情况,这里会出现死循环而TLE,改进方法是将原数据全部+115 int sum(int x)16 {17 int ret=0;18 19 while(x>0)20 {21 re... 阅读全文
posted @ 2014-02-06 21:31 ~~Snail~~ 阅读(168) 评论(0) 推荐(0) 编辑
摘要: N(3N20000)ping pong players live along a west-east street(consider the street as a line segment). Each player has a unique skill rank. To improve their skill rank, they often compete with each other. If two players want to compete, they must choose a referee among other ping pong players and hold th 阅读全文
posted @ 2014-02-06 21:20 ~~Snail~~ 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 1、(UVa 375)设三角形面积为S,三个边长分别为a,b,c,则内切圆半径为:2*S/(a+b+c)2、(UVa 11300) 数轴上有n个点X1,X2,…,Xn,则数轴上到这n个点距离之和最小的点是这n个点坐标的中位数。n为奇数时是中间那个点,n为偶数时是中间两个点之间任意一个点 阅读全文
posted @ 2014-02-02 19:03 ~~Snail~~ 阅读(168) 评论(0) 推荐(0) 编辑
摘要: F. Spreading the WealthProblemA Communist regime is trying to redistribute wealth in a village. They have have decided to sit everyone around a circular table. First, everyone has converted all of their properties to coins of equal value, such that the total number of coins is divisible by the numbe 阅读全文
posted @ 2014-02-02 18:49 ~~Snail~~ 阅读(345) 评论(0) 推荐(0) 编辑
摘要: GCommando WarInput:Standard InputOutput:Standard Output“Waiting for orders we held in the wood, word from the front never cameBy evening the sound of the gunfire was miles awayAh softly we moved through the shadows, slip away through the treesCrossing their lines in the mists in the fields on our ha 阅读全文
posted @ 2014-02-02 10:29 ~~Snail~~ 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Problem C: The Dragon of LoowaterOnce upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem.The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predators, the geese population was out of control. The peo 阅读全文
posted @ 2014-02-02 09:39 ~~Snail~~ 阅读(200) 评论(0) 推荐(0) 编辑
摘要: BookshelfTime Limit:1000MSMemory Limit:65536KTotal Submissions:6990Accepted:3506DescriptionFarmer John recently bought a bookshelf for cow library, but the shelf is getting filled up quite quickly, and now the only available space is at the top.Each of theNcows (1 ≤N≤ 20,000) has some height ofHi(1 阅读全文
posted @ 2014-02-01 22:08 ~~Snail~~ 阅读(507) 评论(0) 推荐(0) 编辑
摘要: IMMEDIATE DECODABILITYTime Limit:1000MSMemory Limit:10000KTotal Submissions:10504Accepted:4971DescriptionAn 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 bin 阅读全文
posted @ 2014-02-01 22:03 ~~Snail~~ 阅读(135) 评论(0) 推荐(0) 编辑
摘要: THE DRUNK JAILERTime Limit:1000MSMemory Limit:10000KTotal Submissions:21957Accepted:13879DescriptionA certain prison contains a long hall of n cells, each right next to each other. Each cell has a prisoner in it, and each cell is locked.One night, the jailer gets bored and decides to play a game. Fo 阅读全文
posted @ 2014-02-01 21:58 ~~Snail~~ 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Problem D: ShellSortHe made each turtle stand on another one's backAnd he piled them all up in a nine-turtle stack.And then Yertle climbed up. He sat down on the pile.What a wonderful view! He could see 'most a mile!The ProblemKing Yertle wishes to rearrange his turtle throne to place his hi 阅读全文
posted @ 2014-01-31 10:02 ~~Snail~~ 阅读(304) 评论(0) 推荐(0) 编辑
摘要: Parentheses BalanceYou are given a string consisting of parentheses()and[]. A string of this type is said to becorrect:(a)if it is the empty string(b)if A and B are correct, AB is correct,(c)if A is correct,(A)and[A]is correct.Write a program that takes a sequence of strings of this type and check t 阅读全文
posted @ 2014-01-31 09:45 ~~Snail~~ 阅读(374) 评论(0) 推荐(0) 编辑
摘要: Inscribed Circles and Isosceles TrianglesGiven two real numbersBthe width of the base of an isosceles triangle in inchesHthe altitude of the same isosceles triangle in inchesCompute to six significant decimal placesCthe sum of the circumferences of a series of inscribed circles stacked one on top of 阅读全文
posted @ 2014-01-31 09:36 ~~Snail~~ 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Problem EThe Other Two TreesInput:standard inputOutput:standard outputTime Limit:2 secondsYou have a quadrilateral shaped land whose opposite fences are of equal length. You have four neighbors whose lands are exactly adjacent to your four fences, thatmeansyou have a common fence with all of them. F 阅读全文
posted @ 2014-01-31 09:12 ~~Snail~~ 阅读(260) 评论(0) 推荐(0) 编辑
摘要: Problem BCode RefactoringTime Limit: 2 seconds"Harry, my dream is a code waiting to bebroken. Break the code, solve the crime."Agent CooperSeveral algorithms in modern cryptography are based on the fact that factoring large numbers is difficult. Alicia and Bobby know this, so they have dec 阅读全文
posted @ 2014-01-31 08:56 ~~Snail~~ 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Problem F: Factoring Large NumbersOne of the central ideas behind much cryptography is that factoring large numbers is computationally intensive. In this context one might use a 100 digit number that was a product of two 50 digit prime numbers. Even with the fastest projected computers this factoriz 阅读全文
posted @ 2014-01-31 08:46 ~~Snail~~ 阅读(236) 评论(0) 推荐(0) 编辑
摘要: Light, more lightThe ProblemThere is man named "mabu" for switching on-off light in our University. He switches on-off the lights in a corridor. Every bulb has its own toggle switch. That is, if it is pressed then the bulb turns on. Another press will turn it off. To save power consumption 阅读全文
posted @ 2014-01-23 20:33 ~~Snail~~ 阅读(406) 评论(0) 推荐(0) 编辑
摘要: Skew BinaryWhen a number is expressed in decimal, thek-th digit represents a multiple of 10k. (Digits are numbered from right to left, where the least significant digit is number 0.) For example,When a number is expressed in binary, thek-th digit represents a multiple of 2k. For example,Inskew binar 阅读全文
posted @ 2014-01-23 20:22 ~~Snail~~ 阅读(242) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 11 下一页