 Table Legs

Description
A table with four legs may rock, even on a flat surface, if its legs are not all the same length. Interestingly, regardless of how many legs have differing lengths, it is always possible to saw an amount from some legs so as to make the table sit level on a flat surface without rocking.
Your job is to generalize this approach to a table with many legs equally spaced around the perimeter of a round table. You are to determine the total length of legs to cut so as to have the table sit level without rocking on a flat surface with not necessarily every leg touching the ground.
InputInput consists of data for a number of tables. For each table, a line will give an integer t, between 3 and 50, indicating the number of legs on the table. t subsequent lines will give, in order around the table's circumference, the lengths of the legs in millimetres. Each leg is perpendicular to the table top. A line containing 0 follows the data for the last table.
OutputPick a strategy that cuts the least total length from all legs and print this amount as an integer number. Print a blank line between tables.
Sample Input3
2000
3000
4000
4
2000
2000
1999
2001
5
2000
2000
1999
2001
1999
0Sample Output
3000
4
1
求救~ 北大ACM题_course
20090912关键是输出，即后面的Sample Output,能解释的解释下吧！！ Description A table with four legs may rock, even on a flat surfa
北大acm 1002 求救_course
20110326网上提供的java源代码 1002题 import java.io.BufferedInputStream; import java.io.DataInputStream; import java.i
COURSES _course
20171026Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is possible to form a committee of exactly P students that satisfies simultaneously the conditions: every student in the committee represents a different course (a student can represent a course if he/she visits that course) each course has a representative in the committee Input Your program should read sets of data from the std input. The first line of the input contains the number of the data sets. Each data set is presented in the following format: P N Count1 Student1 1 Student1 2 ... Student1 Count1 Count2 Student2 1 Student2 2 ... Student2 Count2 ... CountP StudentP 1 StudentP 2 ... StudentP CountP The first line in each data set contains two positive integers separated by one blank: P (1 <= P <= 100)  the number of courses and N (1 <= N <= 300)  the number of students. The next P lines describe in sequence of the courses �from course 1 to course P, each line describing a course. The description of course i is a line that starts with an integer Count i (0 <= Count i <= N) representing the number of students visiting course i. Next, after a blank, you抣l find the Count i students, visiting the course, each two consecutive separated by one blank. Students are numbered with the positive integers from 1 to N. There are no blank lines between consecutive sets of data. Input data are correct. Output The result of the program is on the standard output. For each input data set the program prints on a single line "YES" if it is possible to form a committee and "NO" otherwise. There should not be any leading blanks at the start of the line. Sample Input 2 3 3 3 1 2 3 2 1 2 1 1 3 3 2 1 3 2 1 3 1 1 Sample Output YES NO
The Alphabet Game _course
20171015Description Little Dara has recently learned how to write a few letters of the English alphabet (say k letters). He plays a game with his little sister Sara. He draws a grid on a piece of paper and writes p instances of each of the k letters in the grid cells. He then asks Sara to draw as many sidetoside horizontal and/or vertical bold lines over the grid lines as she wishes, such that in each rectangle containing no bold line, there would be p instances of one letter or nothing. For example, consider the sheet given in Figure 1, where Sara has drawn two bold lines creating four rectangles meeting the condition above. Sara wins if she succeeds in drawing the required lines. Dara being quite fair to Sara, wants to make sure that there would be at least one solution to each case he offers Sara. You are to write a program to help Dara decide on the possibility of drawing the right lines. ![](http://poj.org/images/1231_1.jpg) Input The first line of the input file contains a single integer t (1 <= t <= 10), the number of test cases, followed by the input data for each test case. The first line of each test case consists of two integers k (1 <= k <= 26), the number of different letters, and p (1 <= p <= 10), the number of instances of each letter. Followed by the first line, there are k lines, one for each letter, each containing p pairs of integers (xi, yi) for 1 <= i <= p. A pair indicates coordinates of the cell on the paper where one instance of the letter is written. The coordinates of the upper left cell of the paper is assumed to be (1,1). Coordinates are positive integers less than or equal to 1,000,000. You may assume that no cell contains more than one letter. Output There should be one line per test case containing a single word YES or NO depending on whether the input paper can be divided successfully according to the constraints stated in the problem. Sample Input 2 3 2 6 4 8 4 4 2 2 1 2 3 2 4 3 3 1 1 3 1 5 1 2 1 4 1 6 1 2 2 4 2 8 1 Sample Output YES NO
Ticket to Ride _course
20170523Problem Description Ticket to Ride is a board game for up to 5 players. The goal of the game is to set up train lines (and to thwart the opponents’ attempts at setting up their train lines). At the beginning of play, each player is assigned four train lines. A player may choose to discard as many of these four assignments as she likes. Each assignment has a score, corresponding to its difficulty (so, typically, a train line between e.g. Stockholm and Tokyo would be worth more than a train line between e.g. Stockholm and Utrecht). At the end of the game, each player gets points for the assignments that they have successfully completed, and penalty points for the assignments that they have failed to complete. An assignment consists of a pair of cities that are to be connected by a series of shorter railway routes. A route can be claimed (for a certain cost associated with the route), but things are complicated by the fact that there is only a limited number of routes, and once a player claims a route, none of the other players can claim it. A player has successfully set up a train line between two cities if there is a path between the two cities using only routes that have been claimed by this player. For simplicity, we will ignore all additional aspects of the game (including the actual process of claiming routes and additional ways to score points). For instance, if your assignment is to connect Stockholm and Amsterdam in the Figure above, you would probably want to claim the routes between Stockholm and Copenhagen, and between Copenhagen and Amsterdam. But if another player manages to claim the route between Copenhagen and Stockholm before you, your train line would have to use some other routes, e.g. by going to Copenhagen via Oslo. In this problem, we will consider the rather bold strategy of trying to complete all four assignments (typically, this will be quite hard). As a preliminary assessment of the difficulty of achieving this, we would like to calculate the minimum cost of setting up all four lines assuming that none of the other players interfere with our plans. Your job is to write a program to determine this minimum cost. Input The input consists of several (at most 20) games to be analyzed. Each game starts with two integers 1 <= n <= 30, 0 <= m <= 1 000, giving the number of cities and railway routes in the map, respectively. Then follow n lines, giving the names of the n cities. City names are at most 20 characters long and consist solely of lower case letters (’a’’z’). After this follow m lines, each containing the names of two different cities and an integer 1 <= c <= 10 000, indicating that there is a railway route with cost c between the two cities. Note that there may be several railway routes between the same pair of cities. You may assume that it is always possible to set up a train line from any city to any other city. Finally, there will be four lines, each containing the names of two cities, giving the four train line assignments. The input is terminated by a case where n = m = 0. This case should not be processed. Output For each game, output a single line containing a single integer, the minimum possible cost to set up all four train lines. Sample Input 10 15 stockholm amsterdam london berlin copenhagen oslo helsinki dublin reykjavik brussels oslo stockholm 415 stockholm helsinki 396 oslo london 1153 oslo copenhagen 485 stockholm copenhagen 522 copenhagen berlin 354 copenhagen amsterdam 622 helsinki berlin 1107 london amsterdam 356 berlin amsterdam 575 london dublin 463 reykjavik dublin 1498 reykjavik oslo 1748 london brussels 318 brussels amsterdam 173 stockholm amsterdam oslo london reykjavik dublin brussels helsinki 2 1 first second first second 10 first first first first second first first first 0 0 Sample Output 3907 10
Organize Your Train part II _course
20161108Description RJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The layout of the lines is shown in Figure 1. ![](http://poj.org/images/3007_1.gif) Figure 1: Layout of the exchange lines A freight train consists of 2 to 72 freight cars. There are 26 types of freight cars, which are denoted by 26 lowercase letters from "a" to "z". The cars of the same type are indistinguishable from each other, and each car's direction doesn't matter either. Thus, a string of lowercase letters of length 2 to 72 is sufficient to completely express the configuration of a train. Upon arrival at the exchange lines, a train is divided into two subtrains at an arbitrary position (prior to entering the storage lines). Each of the subtrains may have its direction reversed (using the reversal line). Finally, the two subtrains are connected in either order to form the final configuration. Note that the reversal operation is optional for each of the subtrains. For example, if the arrival configuration is "abcd", the train is split into two subtrains of either 3:1, 2:2 or 1:3 cars. For each of the splitting, possible final configurations are as follows ("+" indicates final concatenation position): [3:1] abc+d cba+d d+abc d+cba [2:2] ab+cd ab+dc ba+cd ba+dc cd+ab cd+ba dc+ab dc+ba [1:3] a+bcd a+dcb bcd+a dcb+a Excluding duplicates, 12 distinct configurations are possible. Given an arrival configuration, answer the number of distinct configurations which can be constructed using the exchange lines described above. Input The entire input looks like the following. the number of datasets = m 1st dataset 2nd dataset ... mth dataset Each dataset represents an arriving train, and is a string of 2 to 72 lowercase letters in an input line. Output For each dataset, output the number of possible train configurations in a line. No other characters should appear in the output. Sample Input 4 aa abba abcd abcde Sample Output 1 6 12 18
Alignment of Code _course
20170110Description You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which is basically a text editor with bells and whistles. You are working on a module that takes a piece of code containing some definitions or other tabular information and aligns each column on a fixed vertical position, while keeping the resulting code as short as possible, making sure that only whitespaces that are absolutely required stay in the code. So, that the first words on each line are printed at position p1 = 1; the second words on each line are printed at the minimal possible position p2, such that all first words end at or before position p2  2; the third words on each line are printed at the minimal possible position p3, such that all second words end at or before position p3  2, etc. For the purpose of this problem, the code consists of multiple lines. Each line consists of one or more words separated by spaces. Each word can contain uppercase and lowercase Latin letters, all ASCII punctuation marks, separators, and other nonwhitespace ASCII characters (ASCII codes 33 to 126 inclusive). Whitespace consists of space characters (ASCII code 32). Input The input file contains one or more lines of the code up to the end of file. All lines (including the last one) are terminated by a standard endofline sequence in the file. Each line contains at least one word, each word is 1 to 80 characters long (inclusive). Words are separated by one or more spaces. Lines of the code can have both leading and trailing spaces. Each line in the input file is at most 180 characters long. There are at most 1000 lines in the input file. Output Write to the output file the reformatted, aligned code that consists of the same number of lines, with the same words in the same order, without trailing and leading spaces, separated by one or more spaces such that ith word on each line starts at the same position pi. Sample Input start: integer; // begins here stop: integer; // ends here s: string; c: char; // temp Sample Output start: integer; // begins here stop: integer; // ends here s: string; c: char; // temp
Round Table _course
20170802Problem Description I have m little buddies, and tonight we will have a fancy dinner in my room. Fortunately, I have a round table which is large enough for all my little buddies. (As for me, I will not sit in the round table for some reasons) And the round table is so large that I will not let my little buddies sit shoulder to shoulder. That means I will select m seats from n seats, and there maximal length of consecutive seats in the original round table won't be larger than or equal to k. I want know how many different ways I can choose. Here is one more thing, two ways are considered the same if and only if one can be obtained by rotation. ![](http://acm.hdu.edu.cn/data/images/C47710051.jpg) The answer may be very large so the answer should modulo 109 + 7. Input The first line has a number T (T <= 200) , indicating the number of test cases. Next each line contain three integer n, m, k (1 <= n <= 105, 1 <= m <= 105, 2 <= k <= 105, m <= n). Output For every case, you should output "Case #t: " at first, without quotes. The t is the case number starting from 1. Then follows the answer, See the sample for more details. Sample Input 3 3 1 2 5 2 2 8 3 2 Sample Output Case #1: 1 Case #2: 1 Case #3: 2
chicken shit_course
20081124who come who dead
Fiber Communications _course
20171016Description Farmer John wants to connect his N (1 <= N <= 1,000) barns (numbered 1..N) with a new fiberoptic network. However, the barns are located in a circle around the edge of a large pond, so he can only connect pairs of adjacent barns. The circular configuration means that barn N is adjacent to barn 1. FJ doesn't need to connect all the barns, though, since only certain pairs of cows wish to communicate with each other. He wants to construct as few connections as possible while still enabling all of these pairs to communicate through the network. Given the list of barns that wish to communicate with each other, determine the minimum number of lines that must be laid. To communicate from barn 1 to barn 3, lines must be laid from barn 1 to barn 2 and also from barn 2 to barn 3(or just from barn 3 to 1,if n=3). Input * Line 1: Two integers, N and P (the number of communication pairs, 1 <= P <= 10,000) * Lines 2..P+1: two integers describing a pair of barns between which communication is desired. No pair is duplicated in the list. Output One line with a single integer which is the minimum number of direct connections FJ needs to make. Sample Input 5 2 1 3 4 5 Sample Output 3
Fourier's Lines _course
20171009Description Joseph Fourier was a great mathematician and physicist and is well known for his mathematic series. Among all the nineteen children in his family, Joseph was the youngest and the smartest. He began to show his interest in mathematics when he was very young. After he grew up, he often corresponded with C. Bonard (a professor of mathematics at Auxerre) by exchanging letters. In one letter written to Bonard, Fourier asked a question: how to draw 17 lines on a plane to make exactly 101 crossings, where each crossing belongs to exactly two lines. Obviously, this is an easy problem, and Figure1 is a solution that satisfies his requirement. Now the problem for you is a universal one. Can we draw N lines on a plane to make exactly M crossings, where each crossing belongs to exactly two lines? If we can, how many pieces, at most, can these lines cut the plane into? ![](http://poj.org/images/1923_1.jpg) Input The input may have several sets of test data. Each set is one line containing two integers N and M (1 <= N <= 100, 0 <= M <= 10000), separated by a space. The test data is followed by a line containing two zeros, which indicates the end of input and should not be processed as a set of data. Output Output one line for each set of input in the following format: Case i: N lines cannot make exactly M crossings. if the drawing of these lines is impossible; or: Case i: N lines with exactly M crossings can cut the plane into K pieces at most. Note: Even if N or M equals to one, you should use the words "lines" and "crossings" in your output. Sample Input 4 3 4 6 4 2 5 11 17 101 0 0 Sample Output Case 1: 4 lines with exactly 3 crossings can cut the plane into 8 pieces at most. Case 2: 4 lines with exactly 6 crossings can cut the plane into 11 pieces at most. Case 3: 4 lines cannot make exactly 2 crossings. Case 4: 5 lines cannot make exactly 11 crossings. Case 5: 17 lines with exactly 101 crossings can cut the plane into 119 pieces at most.
Count the Regions _course
20170910What's the maximum number of regions definable by N zigzag lines, each of which consists of two parallel infinite halflines joined by a straight line segment? Here is an example of 2 zigzag lines yield 12 regions at the most. ![](http://acm.zju.edu.cn/onlinejudge/showImage.do?name=0000%2F1652%2F1652.gif) Input The input consists of a sequence of N (<= 10000), which is the number of the zigzag lines, one per line. Output For each N, you should output the number of the maximum regions. Sample Input 1 2 Sample Output 2 12
Wiping Words _course
20161225Description In this problem, you are given a paragraph of text in terms of a sequence of lines. Each lines contains a number of words which are sequences of lowercase and uppercase letters and are separated by either blank characters or asterisks. A word is wiped out if for each character in that word, there is no letter or asterisk character in the same position in the next line, or the word appears in the last line of the input. If such a case happens, all occurrences of that word in the text is converted to blanks independent of the corresponding characters in the next line. Note that the asterisks and black characters never disappear. Also, note that the words are considered casesensitive. Write a program to read a sequence of lines described above and wipe out as many word as it can iteratively. Input The first line of the input contains a single integer t (1 ≤ t ≤ 20) which is the number of test cases in the input. Each test case contains a sequence of lines containing characters A..Z, a..z, blank and asterisk (*). After each test case, there is a line containing single hash character (#) which is not a part of the lines you must consider in your algorithm. Output For each test case, write the input lines in the output with the wiped out words converted to blanks. Separate outputs for consecutive test cases with lines containing a single hash character. Sample Input 2 ACM is ** # in this world you are in*side the world * # Sample Output ACM ** # you * the * #
Bridged Marble Rings _course
20171024问题描述 : 26 marbles―half yellow and half gray―are distributed between two circles of 13 marbles each. The marbles in each circle can be freely rotated clockwise or counterclockwise. The upper and lower circles are bridged by a smaller circle, which rotates―in the plane of the board―180 degrees, effectively exchanging the three bottommost marbles of the upper circle with the three uppermost marbles of the lower one. The goal is to get all gray marbles to the upper circle and all yellow marbles to the lower one while minimizing the number of times the bridging circle is rotated. 输入: The input is a series of lines, where each line describes an initial board configuration. Each line is a permutation of 13 y’s and 13 g’s. The first half of the line describes the clockwise configuration of the upper circle, and the rest of the line describes the clockwise configuration of the lower one. Of course, each y corresponds to a yellow marble, and each g corresponds to a gray one. The input file will include multiple test cases. Each test case consists of a single line containing some permutation of the string y13g13. All lines (including the last one) are terminated with a newline. The newline immediately follows the last letter on the line. 输出: The input is a series of lines, where each line describes an initial board configuration. Each line is a permutation of 13 y’s and 13 g’s. The first half of the line describes the clockwise configuration of the upper circle, and the rest of the line describes the clockwise configuration of the lower one. Of course, each y corresponds to a yellow marble, and each g corresponds to a gray one. The input file will include multiple test cases. Each test case consists of a single line containing some permutation of the string y13g13. All lines (including the last one) are terminated with a newline. The newline immediately follows the last letter on the line. 样例输入: gggggggggggggyyyyyyyyyyyyy yyyyyggggggggyyyygggggyyyy gyyygyggyyygyyggyyggggyygg ygygygygygygygygygygygygyg 样例输出: 0 2 5 6
AgriNet _course
20171012Description Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms. Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm. The distance between any two farms will not exceed 100,000. Input The input includes several cases. For each case, the first line contains the number of farms, N (3 <= N <= 100). The following lines contain the N x N conectivity matrix, where each element shows the distance from on farm to another. Logically, they are N lines of N spaceseparated integers. Physically, they are limited in length to 80 characters, so some lines continue onto others. Of course, the diagonal will be 0, since the distance from farm i to itself is not interesting for this problem. Output For each case, output a single integer length that is the sum of the minimum length of fiber required to connect the entire set of farms. Sample Input 4 0 4 9 21 4 0 8 17 9 8 0 16 21 17 16 0 Sample Output 28
lines _course
20170818Problem Description John has several lines. The lines are covered on the X axis. Let A is a point which is covered by the most lines. John wants to know how many lines cover A. Input The first line contains a single integer T(1≤T≤100)(the data for N>100 less than 11 cases),indicating the number of test cases. Each test case begins with an integer N(1≤N≤105),indicating the number of lines. Next N lines contains two integers Xi and Yi(1≤Xi≤Yi≤109),describing a line. Output For each case, output an integer means how many lines cover A. Sample Input 2 5 1 2 2 2 2 4 3 4 5 1000 5 1 1 2 2 3 3 4 4 5 5 Sample Output 3 1
Adaboost _course
20171024输入: There are no more than 10 test cases For each case, the first line contains four integers C , N , M,S ( 1<= C <= 20 ,1 ≤ N,M <= 1000, 1<= S <= 50 ,M%2==0), indicating the number of queries , the number of rectangles, the number of images, the size of image .Noting ：all the images are square and the same in size . Then there are N lines. Each line has four integers x1 y1 x2 y2 (x1 <= x2, y1 <= y2, 0 <= x1, x2, y1, y2 < S) .They are the coordinates of the lefttop and the rightbottom points of the rectangle . (y is row ,x is column) Then there are M lines. Each lines has S*S integers. All integers from 0 to 255. The ith Image is face when i is between 1 and M/2 , notface otherwise. Then there are C lines. Each line has M integers. The ith integer is qi indicating to weight of ith image.( 1<= qi <= 2000000 ) 输出: There are no more than 10 test cases For each case, the first line contains four integers C , N , M,S ( 1<= C <= 20 ,1 ≤ N,M <= 1000, 1<= S <= 50 ,M%2==0), indicating the number of queries , the number of rectangles, the number of images, the size of image .Noting ：all the images are square and the same in size . Then there are N lines. Each line has four integers x1 y1 x2 y2 (x1 <= x2, y1 <= y2, 0 <= x1, x2, y1, y2 < S) .They are the coordinates of the lefttop and the rightbottom points of the rectangle . (y is row ,x is column) Then there are M lines. Each lines has S*S integers. All integers from 0 to 255. The ith Image is face when i is between 1 and M/2 , notface otherwise. Then there are C lines. Each line has M integers. The ith integer is qi indicating to weight of ith image.( 1<= qi <= 2000000 ) 样例输入: 1 1 4 1 0 0 0 0 1 4 2 3 1 1 1 1 1 1 4 1 0 0 0 0 1 2 3 4 1 1 1 1 样例输出: Case #1: 1 Case #2: 0
Nikifor _course
20171012Description Nikifor has decided to present the dean of the Department of Mathematics and Mechanics with a linearly independent vector system (you know, that we've just celebrated jubilees of the University and of the Department). A store sells m items of ndimensional vectors, m <= 2000, 3 <= n <= m. For each vector its price ci is known, 0 < i <= m. Nikifor wants to buy n linearly independent vectors paying for them minimal sum of money. Write a program that would determine which vectors Nikifor should buy or would inform that it is impossible to satisfy his requirements. Input The first line of an input contains numbers m and n separated with a space. The next m lines contain the vectors on sale. All of the coordinates are integers with an absolute value not exceeding 2 000. The numbers are separated from each other with a space. The next m lines contain prices ci, one number in each line. The prices are positive integers not exceeding 15 000. Output The first line of an output should contain the minimal amount of money that Nikifor is to pay or the number 0, if Nikifor's requirements cannot be satisfied in this store. If it is possible to make a purchase, then the next n lines should contain the numbers of the vectors that Nikifor should buy. If several sets of such numbers are possible, then you should write one of them which is minimal according to the lexicographic order. Sample Input 5 3 1 0 0 0 1 0 0 0 1 0 0 2 0 0 3 10 20 30 10 10 Sample Output 40 1 2 4
Street Directions _course
20171016Description According to the Automobile Collision Monitor (ACM), most fatal traffic accidents occur on twoway streets. In order to reduce the number of fatalities caused by traffic accidents, the mayor wants to convert as many streets as possible into oneway streets. You have been hired to perform this conversion, so that from each intersection, it is possible for a motorist to drive to all the other intersections following some route. You will be given a list of streets (all twoway) of the city. Each street connects two intersections, and does not go through an intersection. At most four streets meet at each intersection, and there is at most one street connecting any pair of intersections. It is possible for an intersection to be the end point of only one street. You may assume that it is possible for a motorist to drive from each destination to any other destination when every street is a twoway street. Input The input consists of a number of cases. The first line of each case contains two integers n and m. The number of intersections is n (2 <= n <= 1000), and the number of streets is m. The next m lines contain the intersections incident to each of the m streets. The intersections are numbered from 1 to n, and each street is listed once. If the pair i j is present, j i will not be present. End of input is indicated by n = m = 0. Output For each case, print the case number (starting from 1) followed by a blank line. Next, print on separate lines each street as the pair i j to indicate that the street has been assigned the direction going from intersection i to intersection j. For a street that cannot be converted into a oneway street, print both i j and j i on two different lines. The list of streets can be printed in any order. Terminate each case with a line containing a single `#' character. Note: There may be many possible direction assignments satisfying the requirements. Any such assignment is acceptable. Sample Input 7 10 1 2 1 3 2 4 3 4 4 5 4 6 5 7 6 7 2 5 3 6 7 9 1 2 1 3 1 4 2 4 3 4 4 5 5 6 5 7 7 6 0 0 Sample Output 1 1 2 2 4 3 1 3 6 4 3 5 2 5 4 6 4 6 7 7 5 # 2 1 2 2 4 3 1 4 1 4 3 4 5 5 4 5 6 6 7 7 5 #
Partition a Matrix _course
20171017Description Given an M * N matrix consisted of nonnegative elements, you may partition it into three parts with two straight line segments. The line segments cannot go through any element of the matrix and they must be parallel to the row or the column of the matrix, but they need not to be parallel to each other. Each of the three parts is a nonempty matrix, which means it contains at least one element. We define the value of a matrix as the sum of all elements in it. We denote the values of the three remaining matrices as X, Y, Z, and the balance degree as X  Y + Y  Z + Z  X, where . means the absolute value. Among all ways of partition, there is one, which has the least balance degree. Your task is to decide what the least balance degree is. Input The input will consist of several test cases. For each test case, two integers M and N are given in the first line, indicating the number of rows and columns of the matrix; each of the following M lines contains N integers, indicating the matrix. The input is terminated by a single line with two zeros. You may assume that 2 <= M, N <= 500 and all elements of the matrix are integers in the range [0, 65535]. There may be some blank lines between test cases. Output For each matrix of the input, print a line containing the least balance degree. Sample Input 3 3 9 8 7 6 5 4 3 2 1 0 0 Sample Output 10
Doublets _course
20171016Description A Doublet is a pair of words that differ in exactly one letter; for example, "booster" and "rooster" or "rooster" and "roaster" or "roaster" and "roasted". You are given a dictionary of up to 25143 lower case words, not exceeding 16 letters each. You are then given a number of pairs of words. For each pair of words, find the shortest sequence of words that begins with the first word and ends with the second, such that each pair of adjacent words is a doublet. For example, if you were given the input pair "booster" and "roasted", a possible solution would be: ("booster", "rooster", "roaster", "roasted") provided that these words are all in the dictionary. Input Input consists of the dictionary followed by a number of word pairs. The dictionary consists of a number of words, one per line, and is terminated by an empty line. The pairs of input words follow; the words of each pair occur on a line separated by a space. Output For each input pair, print a set of lines starting with the first word and ending with the last. Each pair of adjacent lines must be a doublet. If there are several minimal solutions, any one will do. If there is no solution, print a line: "No solution." Leave a blank line between cases. Sample Input booster rooster roaster coasted roasted coastal postal booster roasted coastal postal Sample Output booster rooster roaster roasted No solution.
三星的上机题，请大神帮助解答。怎么打印出3到10000的数据。_course
20170618You are to find the closest common ancestor of two vertices in a binary tree. For example, the common ancestors of vertices 8 and 13 in the figure below are vertices 3 and 1. Among them, vertex 3 is the closest to the vertex 8 and 13. And the size of subtree (the number of vertices in the subtree) rooted by vertex 3 is 8.![图片说明](https://imgask.csdn.net/upload/201706/18/1497782587_428418.jpg) Given a binary tree and two vertices, write a program that finds the closest common ancestor and computes the size of the subtree rooted by the closest common ancestor. No input is given where one of the two given vertices is an ancestor of the other. For example, ‘11 and 3’ in the above tree is an invalid input. Therefore, your program does not have to consider this case. [Constraints] The number of vertices are from 3 to 10000 [Input] You are given 10 test cases. Each test case has two lines, so the total number of lines is 20. In each test case, the first line consists of four integers, V (the number of vertices in the tree), E (the number of edges), and the indices of two vertices. E edges are listed in the next line. Each edge is represented by two vertices; the index of the parent vertex always precedes the index of the child. For example, the edge connecting vertices 5 and 8 is represented by “5 8”, not by “8 5.” There is no order in which the edges are given. Every consecutive integer in the input is separated by a space. Given 10 test cases, First 4 test cases contain small number of vertices(3, 5, 7, 10 each). Next 6 test cases contain same or greater than 50 vertices. The indices of vertices are integers from 1 to V, and root vertex always has the index 1. It is guaranteed that the parent vertex has smaller index than the child vertex. In this problem, it is not important whether the child is the left child of the parent or the right child; so you can decide this arbitrarily. [Output] Output 10 answers in 10 lines. Each line starts with ‘#x’ meaning the index of a test case, and writes the answer after a space. The answer has two integers: the index of the closest common ancestor and the size of the subtree rooted by the closest common ancestor. These two integers are separated by a space as well. [I/O Example] Input (20 lines in total) 13 12 8 13 ← Start of the first input 1 2 1 3 2 4 3 5 3 6 4 7 7 12 5 9 5 8 6 10 6 11 11 13 10 9 1 10 ← Start of the second input 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 ... Output (10 lines in total) #1 3 8 #2 1 10 ...
Python数据分析与挖掘
2018010892讲视频课+16大项目实战+源码+￥800元课程礼包+讲师社群1V1答疑+社群闭门分享会=99元 为什么学习数据分析？ 人工智能、大数据时代有什么技能是可以运用在各种行业的？数据分析就是。 从海量数据中获得别人看不见的信息，创业者可以通过数据分析来优化产品，营销人员可以通过数据分析改进营销策略，产品经理可以通过数据分析洞察用户习惯，金融从业者可以通过数据分析规避投资风险，程序员可以通过数据分析进一步挖掘出数据价值，它和编程一样，本质上也是一个工具，通过数据来对现实事物进行分析和识别的能力。不管你从事什么行业，掌握了数据分析能力，往往在其岗位上更有竞争力。 本课程共包含五大模块： 一、先导篇： 通过分析数据分析师的一天，让学员了解全面了解成为一个数据分析师的所有必修功法，对数据分析师不在迷惑。 二、基础篇： 围绕Python基础语法介绍、数据预处理、数据可视化以及数据分析与挖掘......这些核心技能模块展开，帮助你快速而全面的掌握和了解成为一个数据分析师的所有必修功法。 三、数据采集篇： 通过网络爬虫实战解决数据分析的必经之路：数据从何来的问题，讲解常见的爬虫套路并利用三大实战帮助学员扎实数据采集能力，避免没有数据可分析的尴尬。 四、分析工具篇： 讲解数据分析避不开的科学计算库Numpy、数据分析工具Pandas及常见可视化工具Matplotlib。 五、算法篇： 算法是数据分析的精华，课程精选10大算法，包括分类、聚类、预测3大类型，每个算法都从原理和案例两个角度学习，让你不仅能用起来，了解原理，还能知道为什么这么做。
 博客 20201020
 博客 直接告诉你EndNote怎么用！
 下载 Asp.net MVC利用knockoutjs实现登陆并记录用户的内外网IP及所在城市(推荐)
 下载 详解物联网技术框架
 博客 建表
 学院 2020年软考网络规划设计师论文写作套路精讲视频课程
 下载 Unity动态模型导入.zip
 博客 回归树构建
 下载 电源技术中的基于NCP1246和NCP4354低待机能耗电源适配器解决方案
 学院 千锋梁哥_2020最新_C语言视频教程（全家桶）
 下载 提高共源共栅CMOS功率放大器效率的方案
 学院 Spring AOP从认识到源码
 下载 基于三次样条函数的数控插补算法研究
 博客 内容管理（八）02删除响应无内容处理 JSONBIG.parse(null) 报错代码最好使用try{}catch(){}，弹出框确认消息组件使用
 博客 手把手教你如何在广交会使用OBS直播丨汇信外贸软件
 下载 低成本交直流两用后备电源的设计
 博客 Technica：以太网解决方案
 博客 要用到的解决方法（大二）
 下载 php获取文件名称和扩展名的方法
 学院 RabbitMQ实战，解决java高并发，MQ企业选型
 博客 wxpython 库开发的.MDB文件读取
 学院 手把手跟我学报表开发实战（Jasperreports）
 学院 CMake工程管理入门精讲
 博客 javascript数字分位显示
 下载 Maven的学习使用
 学院 FFmpeg4.3开发系列之七：WEB音视频转码器Java版
 下载 php实现连接access数据库并转txt写入的方法
 学院 Vue3.0实战豆瓣评分项目
 博客 Beanshell处理Json返回值并断言
 博客 spring boot反爬虫接口防刷组件