02 2013 档案
摘要:Problem BPeter’s SmokesInput:standard inputOutput:standard outputTime Limit:4 secondsMemory Limit:32 MBPeter hasncigarettes. He smokes them one by one keeping all the butts. Out ofk> 1butts he can roll a new cigarette.How many cigarettes can Peter have?InputInput is a sequence of lines. Each line
阅读全文
摘要: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
阅读全文
摘要:Roman DigititisMany persons are familiar with the Roman numerals for relatively small numbers. The symbols ``i", ``v", ``x", ``l", and ``c" represent the decimal values 1, 5, 10, 50, and 100 respectively. To represent other values, these symbols, and multiples where necessar
阅读全文
摘要:Points in Figures: RectanglesGiven a list of rectangles and a list of points in thex-yplane, determine for each point which figures (if any) contain the point.InputThere will ben() rectangles descriptions, one per line. The first character will designate the type of figure (``r'' for rectang
阅读全文
摘要:Odd SumGiven a range[a,b], you are to find the summation of all the odd integers in this range. For example, the summation of all the odd integers in the range[3, 9]is3 + 5 + 7 + 9 = 24.InputThere can be at multiple test cases. The first line of input gives you the number of test cases,T(1T100). The
阅读全文
摘要:Problem EAll in AllInput:standard inputOutput:standard outputTime Limit:2 secondsMemory Limit:32 MBYou have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss
阅读全文
摘要:Problem A - f91Time Limit: 1 secondBackgroundMcCarthy is a famous theorician of computer science. In his work, he defined a recursive function, called f91, that takes as input a positive integerNand returns a positive integer defined as follows:IfN ≤ 100, then f91(N) = f91(f91(N+11));IfN ≥ 101, then
阅读全文
摘要:Binomial ShowdownIn how many ways can you choosekelements out ofnelements, not taking order into account?Write a program to compute this number.Input SpecificationThe input file will contain one or more test cases.Each test case consists of one line containing two integersn() andk().Input is termina
阅读全文
摘要:Problem EPizza CuttingInput:standard inputOutput:standard outputWhen someone calls Ivan lazy, he claims that it is his intelligence that helps him to be so. If his intelligence allows him to do something at less physical effort, why should he exert more? He also claims that he always uses his brain
阅读全文
摘要:Street NumbersA computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks her dog by leaving her house and randomly turning left or right and walking to the end of the street and back. One night she adds up the street numbe
阅读全文
摘要:Quirksome SquaresThe number 3025 has a remarkable quirk: if you split its decimal representation in two strings of equal length (30 and 25) and square the sum of the numbers so obtained, you obtain the original number:The problem is to determine all numbers with this property having a given even num
阅读全文
摘要:Funny Encryption MethodThe ProblemHistory :A student from ITESM Campus Monterrey plays with a new encryption method for numbers. These method consist of the following steps:Steps : Example1) Read the number N to encrypt M = 2652) Interpret N as a decimal number X1= 265 (decimal)3) Convert the decima
阅读全文
摘要:Problem C: Vito's familyBackgroundThe world-known gangster Vito Deadstone is moving to New York. He has a very big family there, all of them living in Lamafia Avenue. Since he will visit all his relatives very often, he is trying to find a house close to them.ProblemVito wants to minimize the to
阅读全文
摘要:Word ScrambleWrite a program that will reverse the letters in each of a sequence of words while preserving the order of the words themselves.InputThe input file will consist of several lines of several words. Words are contiguous stretches of printable characters delimited by white space.OutputThe o
阅读全文
摘要:Fibonacci FreezeThe Fibonacci numbers (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...) are defined by the recurrence:Write a program to calculate the Fibonacci Numbers.Input and OutputThe input to your program would be a sequence of numbers smaller or equal than 5000, each on a separate line, specifying w
阅读全文
摘要:Goldbach's Conjecture (II)Goldbach's Conjecture:For any even numberngreater than or equal to 4, there exists at least one pair of prime numbersp1andp2such thatn=p1+p2.This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can
阅读全文
摘要:Big ModCalculatefor large values ofB,P, andMusing an efficient algorithm. (That's right, this problem has a time dependency !!!.)InputThree integer values (in the orderB,P,M) will be read one number per line.BandPare integers in the range 0 to 2147483647 inclusive.Mis an integer in the range 1 t
阅读全文
摘要:What is the Median?The ProblemMedian plays an important role in the world of statistics. By definition, it is a value which divides an array into two equal parts. In this problem you are to determine the current median of some long integers.Suppose, we have five numbers {1,3,6,2,7}. In this case, 3
阅读全文
摘要:Goldbach's ConjectureIn 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture:Every number greater than 2 can be written as the sum of three prime numbers.Goldbach cwas considering 1 as a primer number, a convention th
阅读全文
摘要:Error CorrectionA boolean matrix has theparity propertywhen each row and each column has an even sum, i.e. contains an even number of bits which are set. Here's a 4 x 4 matrix which has the parity property:1 0 1 00 0 0 01 1 1 10 1 0 1The sums of the rows are 2, 0, 4 and 2. The sums of the column
阅读全文
摘要: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
阅读全文
摘要:What's The Frequency, Kenneth?#include <stdio.h>main(){ int i; char *suffix[]= { "st", "nd", "rd" }; char *item[]= { "Unix" , "cat", "sed", "awk", "grep", "ed", "vi"}; printf("In the be
阅读全文
摘要:Integer InquiryOne of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see the
阅读全文
摘要:Count on CantorOne of the famous proofs of modern mathematics is Georg Cantor's demonstration that the set of rational numbers is enumerable. The proof works by using an explicit enumeration of rational numbers as shown in the diagram below.In the above diagram, the first term is 1/1, the second
阅读全文
摘要:ClockHandsThe medieval interest in mechanical contrivances is well illustrated by the development of the mechanical clock, the oldest of which is driven by weights and controlled by a verge, an oscillating arm engaging with a gear wheel. It dates back to 1386.Clocks driven by springs had appeared by
阅读全文
摘要:Problem B: MinesweeperThe ProblemHave you ever played Minesweeper? It's a cute little game which comes within a certain Operating System which name we can't really remember. Well, the goal of the game is to find where are all the mines within a MxN field. To help you, the game shows a number
阅读全文
摘要:Factors and FactorialsThe factorial of a numberN(writtenN!) is defined as the product of all the integers from 1 toN. It is often defined recursively as follows:Factorials grow very rapidly--5! = 120, 10! = 3,628,800. One way of specifying such large numbers is by specifying the number of times each
阅读全文
摘要:It is said that 90% of frosh expect to be above average in their class. You are to provide a reality check.The first line of standard input contains an integer C, the number of test cases. C data sets follow. Each data set begins with an integer, N, the number of people in the class (1 <= N <=
阅读全文
摘要:PerfectionFrom the article Number Theory in the 1994 Microsoft Encarta: ``Ifa,b,care integers such thata=bc, a is called a multiple ofbor ofc, andborcis called a divisor or factor ofa. Ifcis not,bis called a proper divisor ofa. Even integers, which include 0, are multiples of 2, for example, -4, 0,
阅读全文
摘要:Power CrisisDuring the power crisis in New Zealand this winter (caused by a shortage of rain and hence low levels in the hydro dams), a contingency scheme was developed to turn off the power to areas of the country in a systematic, totally fair, manner. The country was divided up intoNregions (Auckl
阅读全文
摘要:CombinationsComputing the exact number of ways thatNthings can be takenMat a time can be a great challenge whenNand/orMbecome very large. Challenges are the stuff of contests. Therefore, you are to make just such a computation given the following:GIVEN:Compute theEXACTvalue of:You may assume that th
阅读全文
摘要: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
阅读全文
摘要:Problem AEcological PremiumInput:standard inputOutput:standard outputTime Limit:1 secondMemory Limit:32 MBGerman farmers are given a premium depending on the conditions at their farmyard. Imagine the following simplified regulation: you know the size of each farmer's farmyard in square meters an
阅读全文
摘要:What's Cryptanalysis?Cryptanalysis is the process of breaking someone else's cryptographic writing. This sometimes involves some kind of statistical analysis of a passage of (encrypted) text. Your task is to write a program which performs a simple analysis of a given text.InputThe first line
阅读全文
摘要:Box of BricksLittle Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. ``Look, I've built a wall!'', he tells his older sister Alice. ``Nah, you should make all stacks the same height. Then you would have a real wall.'
阅读全文
摘要:Problem C: WERTYUA common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner.Input consists of several line
阅读全文
摘要:Train SwappingAt an old railway station, you may still encounter one of the last remaining ``train swappers''. A train swapper is an employee of the railroad, whose sole job it is to rearrange the carriages of trains.Once the carriages are arranged in the optimal order, all the train driver
阅读全文
摘要:Kindergarten Counting GameEverybody sit down in a circle. Ok. Listen to me carefully.``Woooooo, you scwewy wabbit!''Now, could someone tell me how many words I just said?Input and OutputInput to your program will consist of a series of lines, each line containing multiple words (at least one
阅读全文
摘要:Power of CryptographyBackgroundCurrent work in cryptography involves (among other things) large prime numbers and computing powers of numbers modulo functions of these primes. Work in this area has resulted in the practical use of results from number theory and other branches of mathematics once con
阅读全文
摘要:Maximum SumBackgroundA problem that is simple to solve in one dimension is often much more difficult to solve in more than one dimension. Consider satisfying a boolean expression in conjunctive normal form in which each conjunct consists of exactly 3 disjuncts. This problem (3-SAT) is NP-complete. T
阅读全文
摘要:Ugly NumbersUgly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ...shows the first 11 ugly numbers. By convention, 1 is included.Write a program to find and print the 1500'th ugly number.Input and OutputThere is no input to this progra
阅读全文
摘要:Reverse and AddThe ProblemThe "reverse and add" method is simple: choose a number, reverse its digits and add it to the original. If the sum is not a palindrome (which means, it is not the same number from left to right and right to left), repeat this procedure.For example: 195 Initial num
阅读全文
摘要:Problem B: Primary ArithmeticChildren are taught to add multi-digit numbers from right-to-left one digit at a time. Many find the "carry" operation - in which a 1 is carried from one digit position to be added to the next - to be a significant challenge. Your job is to count the number of
阅读全文
摘要:Problem E: Jolly JumpersA sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1. For instance,1 4 2 3is a jolly jumper, because the absolutes differences are 3, 2, and 1 respectively. The defin
阅读全文
摘要:The DecoderWrite a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and print the exact message that the characters contain. The code key for this simple coding is a one for one character s
阅读全文
摘要:TeX QuotesTeX 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 `` and " to delimit quotations, rather than the mundane " which is what is provided by
阅读全文
摘要:Problem AHashmat the brave warrior Input: standard inputOutput: standard outputHashmat is a brave warrior who with his group of young soldiers moves from one place to another to fight against his opponents. Before fighting he just calculates one thing, the difference between his soldier number and t
阅读全文
摘要:Problem BBack to High School PhysicsInput: standard inputOutput: standard outputA particle has initial velocity and constant acceleration. If its velocity after certain time is v then what will its displacement be in twice of that time?InputThe input will contain two integers in each line. Each line
阅读全文
摘要:Ecological Bin PackingBackgroundBin packing, or the placement of objects of certain weights into different bins subject to certain constraints, is an historically interesting problem. Some bin packing problems are NP-complete but are amenable to dynamic programming solutions or to approximately opti
阅读全文
摘要:100 - The 3n + 1 problemTime limit: 3.000 secondsThe 3n + 1 problemBackgroundProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose classification is not k
阅读全文

浙公网安备 33010602011771号