随笔分类 -  POJ

PKU ACM POJ
POJ 1068 Parencodings
摘要:Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses before the ith right parenthesis in S (P-sequence). q By an integer sequence W = w1 w2...wn where for each right parenthesis, say a in S, we associate an integer which is the number of right parentheses counting from the matched left parenthesis of a up to a. (W-sequence). 阅读全文
posted @ 2011-03-06 22:14 步碎酒散花醉 阅读(733) 评论(0) 推荐(0)
POJ 1102 LC-Display
摘要:A friend of you has just bought a new computer. Until now, the most powerful computer he ever used has been a pocket calculator. Now, looking at his new computer, he is a bit disappointed, because he liked the LC-display of his calculator so much. So you decide to write a program that displays numbers in an LC-display-like style on his computer. 阅读全文
posted @ 2010-09-20 23:53 步碎酒散花醉 阅读(849) 评论(0) 推荐(1)
POJ 1061 青蛙的约会
摘要:两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你被要求写一个程序来判断这两只青蛙是否能够碰面,会在什么时候碰面。 阅读全文
posted @ 2010-09-20 16:29 步碎酒散花醉 阅读(924) 评论(0) 推荐(0)
POJ 1095 Trees Made to Order
摘要:We can number binary trees using the following scheme: The empty tree is numbered 0. The single-node tree is numbered 1. All binary trees having m nodes have numbers less than all those having m+1 nodes. Any binary tree having m nodes with left and right subtrees L and R is numbered n such that all trees having m nodes numbered > n have either Left subtrees numbered higher than L, or A left subtree = L and a right subtree numbered higher than R. 阅读全文
posted @ 2010-09-14 06:08 步碎酒散花醉 阅读(1001) 评论(0) 推荐(1)
POJ 1046 Color Me Less
摘要:A color reduction is a mapping from a set of discrete colors to a smaller one. The solution to this problem requires that you perform just such a mapping in a standard twenty-four bit RGB color space. The input consists of a target set of sixteen RGB color values, and a collection of arbitrary RGB colors to be mapped to their closest color in the target set. For our purposes, an RGB color is defined as an ordered triple (R,G,B) where each value of the triple is an integer from 0 to 255. The dist 阅读全文
posted @ 2010-08-28 23:55 步碎酒散花醉 阅读(354) 评论(3) 推荐(0)
POJ 1088 滑雪
摘要:Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。 阅读全文
posted @ 2010-08-28 03:13 步碎酒散花醉 阅读(373) 评论(0) 推荐(0)
POJ 1026 Cipher
摘要:Bob and Alice started to use a brand-new encoding scheme. Surprisingly it is not a Public Key Cryptosystem, but their encoding and decoding is based on secret keys. They chose the secret key at their last meeting in Philadelphia on February 16th, 1996. They chose as a secret key a sequence of n distinct integers, a1 ; . . .; an, greater than zero and less or equal to n. The encoding is based on the following principle. The message is written down below the key, so that characters in the message 阅读全文
posted @ 2010-08-27 00:43 步碎酒散花醉 阅读(454) 评论(6) 推荐(0)
POJ 1014 Dividing
摘要:Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same value, because then they could just split the collection in half. But unfortunately, some of the marbles are larger, or more beautiful than others. So, Marsha and Bill start by assigning a value, a natural number between one and six, to each marble. Now they want to divide the marbles so that each of 阅读全文
posted @ 2010-08-26 18:38 步碎酒散花醉 阅读(508) 评论(0) 推荐(0)
PKU 1016 Numbers That Count
摘要:Given any non-negative integer n, its inventory is another integer consisting of a concatenation of integers c1 d1 c2 d2 ... ck dk , where each ci and di is an unsigned integer, every ci is positive, the di satisfy 0=d1d2...dk=9, and, for each digit d that appears anywhere in n, d equals di for some i and d occurs exactly ci times in the decimal representation of n. For instance, to compute the inventory of 5553141 we set c1 = 2, d1 = 1, c2 = 1, d2 = 3, etc., giving 21131435. The number 100 阅读全文
posted @ 2010-04-07 20:52 步碎酒散花醉 阅读(480) 评论(0) 推荐(0)
PKU 1006 Biorhythms
摘要:Some people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods of lengths 23, 28, and 33 days, respectively. There is one peak in each period of a cycle. At the peak of a cycle, a person performs at his or her best in the corresponding field (physical, emotional or mental). For example, if it is the mental curve, thought processes will be sharper and concentrat 阅读全文
posted @ 2010-04-07 14:26 步碎酒散花醉 阅读(336) 评论(0) 推荐(0)
PKU 1020 Anniversary Cake
摘要:Nahid Khaleh decides to invite the kids of the "Shahr-e Ghashang" to her wedding anniversary. She wants to prepare a square-shaped chocolate cake with known size. She asks each invited person to determine the size of the piece of cake that he/she wants (which should also be square-shaped). She knows that Mr. Kavoosi would not bear any wasting of the cake. She wants to know whether she can make a square cake with that size that serves everybody exactly with the requested size, and without any was 阅读全文
posted @ 2010-04-07 02:01 步碎酒散花醉 阅读(450) 评论(0) 推荐(0)
PKU 1032 Parliament
摘要:New convocation of The Fool Land's Parliament consists of N delegates. According to the present regulation delegates should be divided into disjoint groups of different sizes and every day each group has to send one delegate to the conciliatory committee. The composition of the conciliatory committee should be different each day. The Parliament works only while this can be accomplished. You are to write a program that will determine how many delegates should contain each group in order for Par 阅读全文
posted @ 2010-04-06 21:01 步碎酒散花醉 阅读(315) 评论(0) 推荐(0)
PKU 1028 Web Navigation
摘要:Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be reached by moving backward and forward. In this problem, you are asked to implement this. The following commands need to be supported: BACK: Push the current page on the top of the forward stack. Pop the page from the top of the backward stack, making it the new current page. If the backward stack 阅读全文
posted @ 2010-04-06 20:51 步碎酒散花醉 阅读(262) 评论(0) 推荐(0)
PKU 1023 The Fun Number System
摘要:In a k bit 2's complement number, where the bits are indexed from 0 to k-1, the weight of the most significant bit (i.e., in position k-1), is -2^(k-1), and the weight of a bit in any position i (0 ≤ i k-1) is 2^i. For example, a 3 bit number 101 is -2^2 + 0 + 2^0 = -3. A negatively weighted bit is called a negabit (such as the most significant bit in a 2's complement number), and a positively weighted bit is called a posibit. A Fun number system is a positional binary number system, where e 阅读全文
posted @ 2010-04-06 20:47 步碎酒散花醉 阅读(321) 评论(0) 推荐(0)
PKU 1013 Counterfeit Dollar
摘要:Sally 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 the real silver dollars. The counterfeit coin has a different weight from the other coins but Sally does not know if it is heavier or lighter than the real coins. Happily, Sally has a friend who loans her a very accurate balance scale. The friend will permit Sally three weighings to find the counterfeit 阅读全文
posted @ 2010-04-06 20:40 步碎酒散花醉 阅读(284) 评论(0) 推荐(0)
PKU 1012 Joseph
摘要:The Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, numbered 1, 2, . . ., n, standing in circle every mth is going to be executed and only the life of the last remaining person will be saved. Joseph was smart enough to choose the position of the last remaining person, thus saving his life to give us the message about the incident. For example when n = 6 and m = 5 then the people will be executed in the order 5, 4, 6, 2, 3 and 阅读全文
posted @ 2010-04-06 20:31 步碎酒散花醉 阅读(288) 评论(0) 推荐(0)
PKU 1008 Maya Calendar
摘要:During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, professor discovered that the Maya civilization used a 365 day long year, called Haab, which had 19 months. Each of the first 18 months was 20 days long, and the names of the months were pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu. Instead of having names, the days of the months were denoted by numbers start 阅读全文
posted @ 2010-04-06 20:19 步碎酒散花醉 阅读(373) 评论(0) 推荐(0)
PKU 1007 DNA Sorting
摘要:One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence ``DAABEC'', this measure is 5, since D is greater than four letters to its right and E is greater than one letter to its right. This measure is called the number of inversions in the sequence. The sequence ``AACEDGG'' has only one inversion (E and D)---it is nearly sorted---while the sequence ``ZWQM'' has 6 inversions (it is as uns 阅读全文
posted @ 2010-04-06 19:51 步碎酒散花醉 阅读(338) 评论(2) 推荐(0)
PKU 1005 I Think I Need a Houseboat
摘要:Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land, he learned that the state of Louisiana is actually shrinking by 50 square miles each year, due to erosion caused by the Mississippi River. Since Fred is hoping to live in this house the rest of his life, he needs to know if his land is going to be lost to erosion. After doing more research, Fred has learned that the land that is being lost forms a semicircle. This sem 阅读全文
posted @ 2010-04-06 19:44 步碎酒散花醉 阅读(237) 评论(0) 推荐(0)
PKU 1004 Financial Management
摘要:Larry graduated this year and finally has a job. He's making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The first step is to figure out what's been going on with his money. Larry has his bank account statements and wants to see how much money he has. Help Larry by writing a program to take his closing balance from each of the past twelve months and calculate his average account 阅读全文
posted @ 2010-04-06 19:40 步碎酒散花醉 阅读(192) 评论(0) 推荐(0)