当前位置:文档之家› POJ水题题目

POJ水题题目

POJ 1247 Magnificent MeatballsMagnificent MeatballsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 5719Accepted: 3837DescriptionSam and Ella run a catering service. They like to put on a show when serving meatballs to guests seated at round tables. They march out of the kitchen with pots of meatballs and start serving adjacent guests. Ella goes counterclockwise and Sam goes clockwise, until they both plop down their last meatball, at the same time, again at adjacent guests. This impressive routine can only be accomplished if they can divide the table into two sections, each having the same number of meatballs. You are to write a program to assist them.At these catering events, each table seats 2 <= N <= 30 guests. Each guest orders at least one and at most nine meatballs. Each place at the table is numbered from 1 to N, with the host at position 1 and the host's spouse at position N. Sam always serves the host first then proceeds to serve guests in increasing order. Ella serves the spouse first, then serves guests in decreasing order. The figures illustrate the first two example input cases.InputInput consists of one or more test cases. Each test case contains the number of guests N followed by meatballs ordered by each guest, from guest 1 to guest N. The end of the input is a line with a single zero.OutputFor each table, output a single line with the ending positions for Sam and Ella, or the sentence indicating an equal partitioning isn't possible. Use the exact formatting shown below.Sample Input5 9 4 2 8 35 3 9 4 2 86 1 2 1 2 1 26 1 2 1 2 1 1Sample OutputSam stops at position 2 and Ella stops at position 3.No equal partitioning.No equal partitioning.Sam stops at position 3 and Ella stops at position 4.SourceMid-Central USA 2002POJ 1316 Self NumbersSelf NumbersTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 18000Accepted: 10125DescriptionIn 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any positive integer n, define d(n) to be n plus the sum of the digits of n. (The d stands for digitadition, a term coined by Kaprekar.) For example, d(75) = 75 + 7 + 5 = 87. Given any positive integer n as a starting point, you can construct the infinite increasing sequence of integers n, d(n), d(d(n)), d(d(d(n))), .... For example, if you start with 33, the next number is 33 + 3 + 3 = 39, the next is 39 + 3 + 9 = 51, the next is 51 + 5 + 1 = 57, and so you generate the sequence33, 39, 51, 57, 69, 84, 96, 111, 114, 120, 123, 129, 141, ...The number n is called a generator of d(n). In the sequence above, 33 is a generator of 39, 39 is a generator of 51, 51 is a generator of 57, and so on. Some numbers have more than one generator: for example, 101 has two generators, 91 and 100. A number with no generators is a self-number.There are thirteen self-numbers less than 100: 1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, and 97.InputNo input for this problem.OutputWrite a program to output all positive self-numbers less than 10000 in increasing order, one per line.Sample InputSample Output135792031425364|| <-- a lot more numbers|9903991499259927993899499960997199829993SourceMid-Central USA 1998POJ 1488 TEX QuotesTEX QuotesTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7464Accepted: 3925DescriptionTEX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hopes, a beautiful document. Beautiful documents use double-left-quote and double-right-quote to delimit quotations, rather than the mundane " which is what is provided by most keyboards. Keyboards typically do not have an oriented double-quote, but they do have a left-single-quote ` and a right-single-quote '. Check your keyboard now to locate the left-single-quote key ` (sometimes called the "backquote key") and the right-single-quote key ' (sometimes called the "apostrophe" or just "quote"). Be careful not to confuse the left-single-quote ` with the "backslash" key \. TEX lets the user type two left-single-quotes `` to create a left-double-quote and two right-single-quotes '' to create a right-double-quote. Most typists, however, are accustomed to delimiting their quotations with the un-oriented double-quote ".If the source contained"To be or not to be," quoth the bard, "that is the question."then the typeset document produced by TEX would not contain the desired form: "To be or not to be," quoth the bard, "that is the question." In order to produce the desired form, the source file must contain the sequence:``To be or not to be,'' quoth the bard, ``that is the question.''You are to write a program which converts text containing double-quote (") characters into text that is identical except that double-quotes have been replaced by the two-character sequences required by TEX for delimiting quotations with oriented double-quotes. The double-quote (") characters should be replaced appropriately by either `` if the " opens a quotation and by '' if the " closes a quotation. Notice that the question of nested quotations does not arise: The first " must be replaced by ``, the next by '', the next by ``, the next by '', the next by ``, the next by '', and so on.InputInput will consist of several lines of text containing an even number of double-quote (") characters. Input is ended with an end-of-file character.OutputThe text must be output exactly as it was input except that:∙the first " in each pair is replaced by two ` characters: `` and∙the second " in each pair is replaced by two ' characters: ''.Sample Input"To be or not to be," quoth the Bard, "thatis the question".The programming contestant replied: "I must disagree.To `C' or not to `C', that is The Question!"Sample Output``To be or not to be,'' quoth the Bard, ``thatis the question''.The programming contestant replied: ``I must disagree.To `C' or not to `C', that is The Question!''SourceEast Central North America 1994POJ 1493 Machined SurfacesMachined SurfacesTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 2173Accepted: 1408DescriptionAn imaging device furnishes digital images of two machined surfaces that eventually will be assembled in contact with each other. The roughness of this final contact is to be estimated.A digital image is composed of the two characters, "X" and " " (space). There are always 25 columns to an image, but the number of rows, N, is variable. Column one (1) will always have an "X" in it and will be part of the left surface. The left surface can extend to the right from column one (1) as contiguous X's.Similarly, column 25 will always have an "X" in it and will be part of the right surface. The right surface can extend to the left from column 25 as contiguous X's.Digital-Image View of SurfacesLeft RightXXXX XXXXX ←1XXX XXXXXXXXXXXX XXXXXX XXXXXX. .. .. .XXXX XXXXXXX XXXXX ←N↑↑1 25In each row of the image, there can be zero or more space characters separating the left surface from the right surface. There will never be more than a single blank region in any row.For each image given, you are to determine the total ``void" that will exist after the left surface has been brought into contact with the right surface. The ``void" is the total count of the spaces that remains between the left and right surfaces after theyhave been brought into contact.The two surfaces are brought into contact by displacing them strictly horizontally towards each other until a rightmost "X" of the left surface of some row is immediately to the left of the leftmost "X" of the right surface of that row. There is no rotation or twisting of these two surfaces as they are brought into contact; they remain rigid, and only move horizontally.Note: The original image may show the two surfaces already in contact, in which case no displacement enters into the contact roughness estimation.InputThe input consists of a series of digital images. Each image data set has the following format:First line -A single unsigned integer, N, with value greater than zero (0) and less than 13. The first digit of N will be the first character on a line.Next N lines -Each line has exactly 25 characters; one or more X's, then zero or more spaces, then one or more X's.The end of data is signaled by a null data set having a zero on the first line of an image data set and no further data.OutputFor each image you receive as a data set, you are to reply with the total void (count of spaces remaining after the surfaces are brought into contact). Use the default output for a single integer on a line.Sample Input4XXXX XXXXXXXX XXXXXXXXXXXX XXXXXX XXXXXX2XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXXXXXXX XXSample OutputSourceEast Central North America 1995POJ 1517 u Calculate eu Calculate eTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 15876 Accepted: 9555 Special Judge DescriptionA simple mathematical formula for e ise=Σ0<=i<=n1/i!where n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n.InputNo inputOutputOutput the approximations of e generated by the above formula for the values of n from 0 to 9. The beginning of your output should appear similar to that shown below. Sample Inputno inputSample Outputn e- -----------0 11 22 2.53 2.6666666674 2.708333333...POJ 1519 Digital RootsDigital RootsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 23459Accepted: 7790DescriptionThe digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24. Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.InputThe input file will contain a list of positive integers, one per line. The end of the input will be indicated by an integer value of zero.OutputFor each integer in the input, output its digital root on a separate line of the output.Sample Input2439Sample Output63SourceGreater New York 2000POJ 1545 Galactic ImportGalactic ImportTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 276Accepted: 143DescriptionWith the introduction of the new ThrustoZoom gigadimensional drive, it has become possible for HyperCommodities, the import/export conglomerate from New Jersey, to begin trading with even the most remote galaxies in the universe. HyperCommodities wants to import goods from some of the galaxies in the Plural Z sector. Planets within these galaxies export valuable products and raw materials like vacuuseal, transparent aluminum, digraphite, and quantum steel. Preliminary reports have revealed the following facts:∙Each galaxy contains at least one and at most 26 planets. Each planet within a galaxy is identified by a unique letter from A to Z.∙Each planet specializes in the production and export of one good. Different planets within the same galaxy export different goods.∙Some pairs of planets are connected by hyperspace shipping lines. If planets A and B are connected, they can trade goods freely. If planet C is connected to B but not to A, then Aand C can still trade goods with each other through B, but B keeps 5% of the shipment asa shipping fee. (Thus A only receives 95% of what C shipped, and C receives only 95% ofwhat A shipped.) In general, any two planets can trade goods as long as they areconnected by some set of shipping lines, but each intermediate planet along the shippingroute keeps 5% of what it shipped (which is not necessarily equal to 5% of the originalshipment).∙At least one planet in each galaxy is willing to open a ThrustoZoom shipping line to Earth.A ThrustoZoom line is the same as any other shipping line within the galaxy, as far asbusiness is concerned. For example, if planet K opens a ThrustoZoom line to Earth, thenthe Earth can trade goods freely with K, or it can trade goods with any planet connectedto K, subject to the usual shipping fees.HyperCommodities has assigned a relative value (a positive real number less than 10) to each planet's chief export. The higher the number, the more valuable the product. More valuable products can be resold with a higher profit margin in domestic markets. The problem is to determine which planet has the most valuable export when shipping fees are taken into account.InputThe input consists of one or more galaxy descriptions. Each galaxy description begins with a line containing an integer N which specifies the number of planets in the galaxy. The next N lines contain descriptions of each planet, which consist of:1.The letter used to represent the planet.2. A space.3.The relative value of the planet's export, in the form d.dd.4. A space.5. A string containing letters and/or the character `*'; a letter indicates a shipping line to thatplanet, and a `*' indicates a willingness to open a ThrustoZoom shipping line to Earth. OutputFor each galaxy description, output a single line which reads "Import from P" where P is the letter of the planet with the most valuable export, once shipping fees have been taken into account. (If more than one planet have the same most valuable export value then output the plant which is alphabetically first).Sample Input1F 0.81 *5E 0.01 *AD 0.01 A*C 0.01 *AA 1.00 EDCBB 0.01 A*10S 2.23 Q*A 9.76 CK 5.88 MIE 7.54 GCM 5.01 OKG 7.43 IEI 6.09 KGC 8.42 EAO 4.55 QMQ 3.21 SOSample OutputImport from FImport from AImport from ASourceMid-Central USA 1995POJ 1547 Clay BullyClay BullyTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7660Accepted: 4309DescriptionMs. Terry is a pre-school art teacher who likes to have her students work with clay. One of her assignments is to form a lump of clay into a block and then measure the dimensions of the block. However, in every class, there is always one child who insists on taking some clay from some other child. Since Ms. Terry always gives every child in a class the same amount of clay to begin with, you can write a program that helps Ms. Terry find the bully and victim after she measures each child's finished block.InputThere are one or more classes of students, followed by a final line containing only the value -1. Each class starts with a line containing an integer, n, which is the number of students in the class, followed by n lines of student information. Each line of student information consists of three positive integers, representing the dimensions of the clay block, followed by the student's first name. There can never be more than 9 students nor less than 2 students in any class. Each student's name is at most 8 characters. Ms. Terry always gives each student at most 250 cubic units of clay. There is exactly one bully and one victim in each class.OutputFor each class print a single line exactly as shown in the sample output.Sample Input310 10 2 Jill5 3 10 Will5 5 10 Bill42 4 10 Cam4 3 7 Sam8 11 1 Graham6 27 Pam-1Sample OutputBill took clay from Will.Graham took clay from Cam.SourceMid-Central USA 2003POJ 1552 DoublesDoublesTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 16404Accepted: 9390DescriptionAs part of an arithmetic competency program, your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in each list are twice some other item in the same list. You will need a program to help you with the grading. This program should be able to scan the lists and output the correct answer for each one. For example, given the list1 4 32 9 7 18 22your program should answer 3, as 2 is twice 1, 4 is twice 2, and 18 is twice 9.InputThe input will consist of one or more lists of numbers. There will be one list of numbers per line. Each list will contain from 2 to 15 unique positive integers. No integer will be larger than 99. Each line will be terminated with the integer 0, which is not considered part of the list. A line with the single number -1 will mark the end of the file. The example input below shows 3 separate lists. Some lists may not contain any doubles.OutputThe output will consist of one line per input list, containing a count of the items that are double some other item.Sample Input1 4 32 9 7 18 22 02 4 8 10 07 5 11 13 1 3 0-1Sample Output32SourceMid-Central USA 2003POJ 1575 Easier Done Than Said?Easier Done Than Said?Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 3711Accepted: 2068DescriptionPassword security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (like xvtpzyo), but users have a hard time remembering them and sometimes leave them written on notes stuck to their computer. One potential solution is to generate "pronounceable" passwords that are relatively secure but still easy to remember.FnordCom is developing such a password generator. You work in the quality control department, and it's your job to test the generator and make sure that the passwords are acceptable. To be acceptable, a password must satisfy these three rules:It must contain at least one vowel.It cannot contain three consecutive vowels or three consecutive consonants.It cannot contain two consecutive occurrences of the same letter, except for 'ee' or 'oo'.(For the purposes of this problem, the vowels are 'a', 'e', 'i', 'o', and 'u'; all other letters are consonants.) Note that these rules are not perfect; there are many common/pronounceable words that are not acceptable.InputThe input consists of one or more potential passwords, one per line, followed by a line containing only the word 'end' that signals the end of the file. Each password is at least one and at most twenty letters long and consists only of lowercase letters.OutputFor each password, output whether or not it is acceptable, using the precise format shown in the example.Sample InputatvptouibontreszoggaxwiinqeephouctuhendSample Output<a> is acceptable.<tv> is not acceptable.<ptoui> is not acceptable.<bontres> is not acceptable.<zoggax> is not acceptable.<wiinq> is not acceptable.<eep> is acceptable.<houctuh> is acceptable.SourceMid-Central USA 2000POJ 1657 Distance on ChessboardDistance on ChessboardTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 21169Accepted: 7296 Description国际象棋的棋盘是黑白相间的8 * 8的方格,棋子放在格子中间。

相关主题