当前位置:文档之家› 哈希表和二分查找等高效查找法(数的Hash,串的Hash)

哈希表和二分查找等高效查找法(数的Hash,串的Hash)

3349Snowflake Snow SnowflakesTime Limit: 4000MS Memory Limit: 65536KTotal Submissions: 22532 Accepted: 5874 DescriptionYou may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Your program will read information about a collection of snowflakes, and search for a pair that may be identical. Each snowflake has six arms. For each snowflake, your program will be provided with a measurement of the length of each of the six arms. Any pair of snowflakes which have the same lengths of corresponding arms should be flagged by your program as possibly identical.InputThe first line of input will contain a single integer n, 0 < n≤ 100000, the number of snowflakes to follow. This will be followed by n lines, each describing a snowflake. Each snowflake will be described by a line containing six integers (each integer is at least 0 and less than 10000000), the lengths of the arms of the snow ake. The lengths of the arms will be given in order around the snowflake (either clockwise or counterclockwise), but they may begin with any of the six arms. For example, the same snowflake could be described as 1 2 3 4 5 6 or 4 3 2 1 6 5.OutputIf all of the snowflakes are distinct, your program should print the message:No two snowflakes are alike.If there is a pair of possibly identical snow akes, your program should print the message:Twin snowflakes found.Sample Input21 2 3 4 5 64 3 2 1 6 5Sample OutputTwin snowflakes found.SourceCCC 20073274Gold Balanced LineupTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 8499 Accepted: 2500 DescriptionFarmer John's N cows (1 ≤ N≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K≤ 30). For example, cows exhibiting feature #1 might have spots, cows exhibiting feature #2 might prefer C to Pascal, and so on.FJ has even devised a concise way to describe each cow in terms of its "feature ID", a single K-bit integer whose binary representation tells us the set of features exhibited by the cow. As an example, suppose a cow has feature ID = 13. Since 13 written in binary is 1101, this means our cow exhibits features 1, 3, and 4 (reading right to left), but not feature 2. More generally, we find a 1 in the 2^(i-1) place if a cow exhibits feature i.Always the sensitive fellow, FJ lined up cows 1..N in a long row and noticed that certain ranges of cows are somewhat "balanced" in terms of the features the exhibit. A contiguous range of cows i..j is balanced if each of the K possible features is exhibited by the same number of cows in the range. FJ is curious as to the size of the largest balanced range of cows. See if you can determine it.InputLine 1: Two space-separated integers, N and K.Lines 2..N+1: Line i+1 contains a single K-bit integer specifying the features present in cow i. The least-significant bit of this integer is 1 if the cow exhibits feature #1, and the most-significant bit is 1 if the cow exhibits feature #K.OutputLine 1: A single integer giving the size of the largest contiguous balanced group of cows.Sample Input7 37672142Sample Output4HintIn the range from cow #3 to cow #6 (of size 4), each feature appears in exactly 2 cows in this rangeSourceUSACO 2007 March Gold2151Check the difficulty of problemsTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 2995 Accepted: 1321 DescriptionOrganizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually expect the contest result satisfy the following two terms:1. All of the teams solve at least one problem.2. The champion (One of those teams that solve the most problems) solves at least a certain number of problems.Now the organizer has studied out the contest problems, and through the result of preliminary contest, the organizer can estimate the probability that a certain team can successfully solve a certain problem.Given the number of contest problems M, the number of teams T, and the number of problems N that the organizer expect the champion solve at least. We also assume that team i solves problem j with the probability Pij (1 <= i <= T, 1<= j <= M). Well, can you calculate the probability that all of the teams solve at least one problem, and at the same time the champion team solves at least N problems?InputThe input consists of several test cases. The first line of each test case contains three integers M (0 < M <= 30), T (1 < T <= 1000) and N (0 < N <= M). Each of the following T lines contains M floating-point numbers in the range of [0,1]. In these T lines, the j-th number in the i-th line is just Pij. A test case of M = T = N = 0 indicates the end of input, and should not be processed.OutputFor each test case, please output the answer in a separate line. The result should be rounded to three digits after the decimal point.Sample Input2 2 20.9 0.91 0.90 0 0Sample Output0.972SourcePOJ Monthly,鲁小石1840EqsTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 8490 Accepted: 4191DescriptionConsider equations having the following form:a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0The coefficients are given integers from the interval [-50,50].It is consider a solution a system (x1, x2, x3, x4, x5) that verifies the equation, xi∈[-50,50], xi != 0, any i∈{1,2,3,4,5}.Determine how many solutions satisfy the given equation.InputThe only line of input contains the 5 coefficients a1, a2, a3, a4, a5, separated by blanks.OutputThe output will contain on the first line the number of the solutions for the given equation.Sample Input37 29 41 43 47Sample Output654SourceRomania OI 20022002SquaresTime Limit: 3500MS Memory Limit: 65536KTotal Submissions: 11836 Accepted: 4335 DescriptionA square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating about its centre by 90 degrees gives the same polygon. It is not the only polygon with the latter property, however, as a regular octagon also has this property.So we all know what a square looks like, but can we find all possible squares that can be formed from a set of stars in a night sky? To make the problem easier, we will assume that the night sky is a 2-dimensional plane, and each star is specified by its x and y coordinates.InputThe input consists of a number of test cases. Each test case starts with the integer n (1 <= n <= 1000) indicating the number of points to follow. Each of the next n lines specify the x and y coordinates (two integers) of each point. You may assume that the points are distinct and the magnitudes of the coordinates are less than 20000. The input is terminated when n = 0.OutputFor each test case, print on a line the number of squares one can form from the given stars.Sample Input41 00 11 10 090 01 02 00 21 22 20 11 12 14-2 53 70 05 2Sample Output161SourceRocky Mountain 2004BabelfishTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 24207 Accepted: 10374 DescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.InputInput consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.OutputOutput is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".Sample Inputdog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslaySample OutputcatehloopsHintHuge input and output,scanf and printf are recommended.SourceWaterloo local 2001.09.22。

相关主题