``````这个地方已经卡了我很久，搜遍整个网络都没有找到具体的解决方法，请求各位大牛看看到底该怎么解决这个问题呢？感激不尽！！
``````

Snakermaster 问题已经解决了，是创建虚拟机时分配的内存太小，这套系统默认是50G,但我只给了他20个G，希望新手朋友勿入此坑

1个回答

Parking Ships 问题求解
Problem Description Life on the great oceans has been good for captain Blackbeard and his fellow pirates. They have gathered so many treasures, that each of them is able to buy a house on their favorite island. The houses on this island are all placed in a long row along the beach line of the island. Next to a house, every pirate is also able to buy his own ship to do their own bit of plundering. However, this causes a whole new kind of problem. Along the beach line there is a long pier where every pirate can park his ship. Although there is enough space along the pier for all the ships, not every pirate will be able to park in front of his house. A pirate is happy with his parking space if some part of the parking space is in front of the center of his house. Captain Blackbeard has been given the diffcult task of assigning the parking spaces to the pirates. A parking space for a pirate i is a range [ai, bi] (ai, bi∈R) along the pier such that li<= bi - ai, where li is the length of the ship of pirate i. Thus, pirate i is happy if ai <= xi <= bi, where xi is the center of the house of pirate i. Clearly, parking spaces of different pirates must be interior disjoint (the ends of ranges can coincide). Above all, the captain wants a good parking space for himself, so he gives himself the parking space such that the center of his ship is aligned with the center of his house. Next to that, he wants to make as many pirates happy as possible. Can you help him out? Input The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format: 1.One line with one integer n (1 <= n <= 1,000): the number of pirates including the captain. 2.n lines with on each line two integers xi (-10^9 <= xi <= 10^9) and li (1 <= li <= 10^9): the center of the house of the ith pirate and the total length of his ship, respectively. The first pirate in the input is always the captain. Output For every test case in the input, the output should contain one integer on a single line: the maximum number of happy pirates using an optimal assignment of the parking spaces. This number includes the captain himself. You can assume that the space along the pier is unbounded in both directions. Sample Input 2 5 0 6 -5 2 -4 1 4 2 5 3 4 0 4 -5 4 3 4 5 3 Sample Output 5 3
Crash and Go(relians) 怎么实现的
Su-domino-ku 数独问题
Problem Description As if there were not already enough sudoku-like puzzles, the July 2009 issue of Games Magazine describes the following variant that combines facets of both sudoku and dominos. The puzzle is a form of a standard sudoku, in which there is a nine-by-nine grid that must be filled in using only digits 1 through 9. In a successful solution: Each row must contain each of the digits 1 through 9. Each column must contain each of the digits 1 through 9. Each of the indicated three-by-three squares must contain each of the digits 1 through 9. For a su-domino-ku, nine arbitrary cells are initialized with the numbers 1 to 9. This leaves 72 remaining cells. Those must be filled by making use of the following set of 36 domino tiles. The tile set includes one domino for each possible pair of unique numbers from 1 to 9 (e.g., 1+2, 1+3, 1+4, 1+5, 1+6, 1+7, 1+8, 1+9, 2+3, 2+4, 2+5, ...). Note well that there are not separate 1+2 and 2+1 tiles in the set; the single such domino can be rotated to provide either orientation. Also, note that dominos may cross the boundary of the three-by-three squares (as does the 2+9 domino in our coming example). To help you out, we will begin each puzzle by identifying the location of some of the dominos. For example, Figure 1 shows a sample puzzle in its initial state. Figure 2 shows the unique way to complete that puzzle. Input Each puzzle description begins with a line containing an integer N, for 10 ≤ N ≤ 35, representing the number of dominos that are initially placed in the starting configuration. Following that are N lines, each describing a single domino as U LU V LV. Value U is one of the numbers on the domino, and LU is a two-character string representing the location of value U on the board based on the grid system diagrammed in Figure 1. The variables V and LV representing the respective value and location of the other half of the domino. For example, our first sample input beings with a domino described as 6 B2 1 B3. This corresponds to the domino with values 6+1 being placed on the board such that value 6 is in row B, column 2 and value 1 in row B, column 3. The two locations for a given domino will always be neighboring. After the specification of the N dominos will be a final line that describes the initial locations of the isolated numbers, ordered from 1 to 9, using the same row-column conventions for describing locations on the board. All initial numbers and dominos will be at unique locations. The input file ends with a line containing 0. Output For each puzzle, output an initial line identifying the puzzle number, as shown below. Following that, output the 9x9 sudoku board that can be formed with the set of dominos. There will be a unique solution for each puzzle. Sample Input 10 6 B2 1 B3 2 C4 9 C3 6 D3 8 E3 7 E1 4 F1 8 B7 4 B8 3 F5 2 F6 7 F7 6 F8 5 G4 9 G5 7 I8 8 I9 7 C9 2 B9 C5 A3 D9 I4 A9 E5 A2 C6 I1 11 5 I9 2 H9 6 A5 7 A6 4 B8 6 C8 3 B5 8 B4 3 C3 2 D3 9 D2 8 E2 3 G2 5 H2 1 A2 8 A1 1 H8 3 I8 8 I3 7 I4 4 I6 9 I7 I5 E6 D1 F2 B3 G9 H7 C9 E5 0 Sample Output Puzzle 1 872643195 361975842 549218637 126754983 738169254 495832761 284597316 657381429 913426578 Puzzle 2 814267593 965831247 273945168 392176854 586492371 741358629 137529486 459683712 628714935
A No-Win Situation 博弈问题
Problem Description Consider a simple variation of the card game Blackjack. In this game, a single player plays against the dealer. The game uses a standard deck of cards, where numbered cards are worth the number of points on the card for the cards numbered 2 to 10, 10 points for the face cards (King, Queen, and Jack) and either 1 or 11 points for the Aces. The dealer deals the first card in the deck to the player, the second to the dealer, the third to the player, and the fourth to the dealer. The player then may continue to draw cards until s/he decides that the total is as close as possible to 21 and stops voluntarily or until s/he goes over 21. If the player goes over 21, the player loses. Then the dealer must draw cards until s/he reaches 17 or more points (with aces counting as 11 when possible). If the dealer goes over 21, the dealer loses. If neither of them goes over 21, the winner is the one who comes as close as possible to 21. If the player and the dealer have the same total, the player wins. For example, suppose the first cards in the deck are Queen, 6, 4, 9, and 10. On the initial deal, the player will receive Queen and 4 (for a total of 14) and the dealer will receive 6 and 9 (for a total of 15). If the player does not select a card, the dealer will have to draw (because the dealer's total is less than 17) and will draw the 10, going over, so the player will win. But if the player draws a card (the 10), the player's total will be 24, so the player will lose. In some situations, it is impossible for the player to win. Consider the case when the cards in the deck are: 10, 3, 4, King, 3, 5. The player will be dealt the cards 10 and 4. The dealer will have 3 and King. The table below illustrates what happens for each number of cards the player might draw: No matter how many cards the player draws, the player cannot win. In this problem, you will analyze decks to determine if they lead to a situation in which the player cannot win. Input The input to the program will be one or more decks. Each deck will be represented by a string, on its own line. Each deck will consist of at least 4 cards. where a card is either an integer d , 2<=d<=9 ,epresenting a numbered card, or one of the letters A, K, Q, J or T, representing Ace, King, Queen, Jack, or Ten, respectively. The letters will be in upper case. There will be no other characters on a line. In particular, there will be no spaces. There will always be enough cards to try all valid draws. End of input is indicated by the word `JOKER', alone on a line. Output Print a list of responses for the input sets, one per line. Print the word `Yes' if there is a number of cards the player can draw and win, and `No' if there is no way for the player to win. Print these words exactly as they are shown. Do not print any blank lines between outputs. Sample Input Q649T T34K35 AA2T34A5KKQAJ JOKER Sample Output Yes No Yes
Enumeration? 枚举的问题
Problem Description In mathematics and theoretical computer science, the broadest and most abstract definition of an enumeration of a set is an exact listing of all of its elements (perhaps with repetition). If we are blocked by a tricky but small issue, a good way is stop bothering and calculating, and just enumerates all the possible result. Here is such a case. iSea is fond of coins recently, now he gets three coins, after throwing all of them again and again, he finds some of those coins are not side equivalent, because the times it faces up and faces down are not equal. Here we assume iSea has thrown the coin enough times that we can treat this as random happened and use the number to count probability. iSea is a typical Libra, placing in equilibrium at the first position always. He want to distribute the probability to the three coins, and each time he chooses a coin from them with this probability, throws the coin, records facing up or down, and this time after summing up all the times whether the coins face up or down the ideal probable number should be perfectly equal. Again, is this possible? Remember the probability for each coin can’t be zero. Input The first line contains a single integer T, indicating the number of test cases. Each test case includes Six integers Up1, Down1, Up2, Down2, Up3, Down3, indicating the times facing up and down of the first, second and third coin, respectively. Technical Specification 1. 1 <= T <= 10 000 2. 1 000 000 <= Up, Down <= 2 000 000 Output For each test case, output the case number first, if possible, output "Yes", otherwise output "No" (without quote). Sample Input 2 1000000 1000001 1000000 1000002 1000000 1000003 1000000 1000001 1000000 1000002 2000000 1000003 Sample Output Case 1: No Case 2: Yes
QR 的问题
Problem Description QR Codes (the smallest, which is 21 pixels by 21 pixels, is shown below) are square arrays of black or white pixels (modules) which include Position Detection Patterns (the square bull's-eye patterns), Timing Patterns (the alternating black and white lines), Alignment Patterns in larger QR Codes , Format Information (the stippled pixels), Version information in larger QR Codes and Data and Error Correction Codewords (gray 8 pixel blocks). The 21-by-21 QR Code has 26 data and error correction codewords. At the lowest error correction level for this code, 19 are data codewords and 7 are error correction codewords. Data may be encoded as numeric at 3 numbers per 10 bits, as alphanumeric at 2 characters per 11 bits, as 8 bit bytes or as Kanji at 13 bits per character. Data is encoded in groups of（mode,character count,character data bits）.The mode can change within the data stream. The mode is specified by a 4 bit code and the character count by a varying number of bits depending on the mode and QR Code size. For the 21-by-21 code, the character count bits are: The entire data stream ends in the termination code which may be truncated if there is not enough room. Any partially filled codeword after the termination code is filled with 0 bits. Any remaining codewords are set to 11101100 followed by 00010001 alternating. Numeric strings are encoded 3 digits at a time. If there are remaining digits, 2 digits are encoded in 7 bits or 1 digit in 4 bits. For example: 12345678 -> 123 456 78 -> 0001111011 0111001000 1001110 Prefix with mode (0001) and count (8 -> 0000001000) is (4 + 10 + 10 + 10 +7) bits: 0001 0000001000 0001111011 0111001000 1001110 Alphanumeric strings encode the haracters (<SP> represents the space character): 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ<SP>\$%*+-./: as numbers from 0 to 44, then two characters are encoded in 11 bits: <first char code5> * 45 + <second char code> if the number of characters is odd, the last character is encoded in 6 bits. For example: AC-42 -> (10,12,41,4,2) -> 10*45+12=462, 41*45+4=1849, 2->00111001110 11100111001 000010 Prefix with mode and count is (4 + 9 + 11 + 11+ 6) bits: 0010 000000101 00111001110 11100111001 000010 The 8 bit binary and Kanji modes will be straightforward for the purposes of this problem. Kanji codes will just be opaque 13 bit codes; you need not decode the characters they represent, just the hexadecimal values. For example: 8 bit 0x45 0x92 0xa3 -> 01000101 10010010 10100011 Prefix with mode and count is (4 + 8 + 8 + 8 + 8) bits: 0100 00000011 01000101 10010010 10100011 Kanji 0x1ABC 07x0345 -> 1101010111100 0001101000101 Prefix with mode and count is (4 + 8 + 13 + 13) bits: 1000 00000010 1101010111100 0001101000101 To illustrate forming the 19 codeword content of a QR Code, combine the first 3 sequences above (for numeric, alphanumeric and bytes). Concatenate the bits, split into 8bit code words add the termination codeword, any fill bits and fill bytes (41 + 41 + 36 data bits + 4 bit termination code = 122 -> 6 fill bits are needed to get 16 bytes, and to fill out the 19 bytes, 3 fill bytes are needed): 0001 0000001000 0001111011 0111001000 1001110 0010 000000101 00111001110 11100111001 000010 0100 00000011 01000101 10010010 10100011 0000 000000 11101100 00010001 11101100 split into 8 bit codewords: 00010000 00100000 01111011 01110010 00100111 00010000 00010100 11100111 01110011 10010000 10010000 00001101 00010110 01001010 10001100 00000000 11101100 00010001 11101100 -> HEX 10207B72271014E77390900D164A8C0EC11EC Write a program to read 19 codewords and print the orresponding data. Input The first line of input contains a single integer P, (1 <= P <= 1000), which is the number of data sets that follow. Each data set is a single line of input consisting of the data set number, N, followed by a single space and 38 hexadecimal digits giving the 19 bytes of QR Code data. The valid hexadecimal digits are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F. Output For each data set there is one line of output. It contains the data set number (N) followed by a single space, the number of QR decoded characters in the result, a single space and the character string corresponding to the QR Code data. In the output string, printable ASCII characters (in the range 0x20 to 0x7e) are printed as the ASCII character EXCEPT that backslash (\) is printed as \\ and pound sign (#) is printed as \#. Non-printable 8 bit data is output as \xx, where x is a hexadecimal digit (e.g. \AE). Non-printable 8 bit data is any value that is less than the ASCII value of a space (0x20) or greater than 0x76. 13 bit Kanji values are printed as #bxxx, where b is 0 or 1 and x is a hexadecimal digit (e.g. #13AC). Sample Input 4 1 10207B72271014E77390900D164A8C00EC11EC 2 802D5E0D1400EC11EC11EC11EC11EC11EC11EC 3 20BB1AA65F9FD7DC0ED88C973E15EF533EB0EC 4 2010B110888D9428D937193B9CEA0D7F45DF68 Sample Output 1 16 12345678AC-42E\92\A3 2 2 #1ABC#0345 3 23 HTTP://WWW.ACMGNYR.ORG/ 4 36 3.1415926535897932384626433832795028
Happy Girls 时间的问题
Problem Description These days, Hunan TV host the big concert – Happy Girls. Long1 and xinxin like it very much, they even use their cellphones to suppose the girl who they like most. This way is easy if you have enough money then you can make a contribution toward your lover. But sometimes, it also causes the problem of injustice. Those who has a lot of money can support their lover in every second. So now, we make a rule to restrict them – every tel-number can just support once in one minute (i.e two messages should have difference bigger or equal 60s). As an exerllent programer, your mission is to count every Happy girl’s result. Input There are many cases. For every case: The first line gives N, represents there are N happy gilrs numbered form 1 to N（N<=10） Then many lines follows(no more than 50000), each line gives the time one sent his/her message, the cellphone number and the number he/she support. They are sepatated by space. The last line an message “#end”. Output In every case, you print “The result is : ”, then N line follows. Each line begin with the Happy girls’ number, then a colon, then a bunch of “*” follows, the number of the “*” are Happy girls’ votes. Sample Input 4 0:12:25 13854241556 1 0:15:52 15825422365 2 0:15:56 15825422365 3 0:18:55 13625415457 2 11:12:2 13954215455 4 5:41:55 13625415457 2 #end Sample Output The result is : 01 : * 02 : *** 03 : 04 : *
Close Enough Computations 的计算
Problem Description The nutritional food label has become ubiquitous. A sample label is shown to the right. On the label the number of calories and the number of grams of fat, carbohydrate, and protein are given as integers. But carefully reading the label may cause the consumer to notice some inconsistencies. A gram of fat has 9 calories, a gram of carbohydrate has 4 calories, and a gram of protein has 4 calories. Consider the label to the right. A simple computation of the number of calories would indicate that the food should contain 12*9 + 31*4 + 5*4 or 252 calories, but the label indicates it has 250 calories. While sometimes the difference in calories is due to other circumstances (such as the presence of alcohol or soluble fiber), this problem will consider only the possibility of round-off error. This food actually has 12.1 grams of fat (yielding 108.9 calories), 30.6 grams of carbohydrate (122.4 calories), 4.7 grams of protein (18.8 calories), so it does in fact have 250 calories (actually 250.1 calories). Write a program that will determine if values for a nutritional label are consistent, that is, if there is a way the true values for the grams of nutrients can be rounded to the shown values and yield the number of calories shown. You should assume that standard rounding rules apply; that is any value less than 0.5 rounds down and those 0.5 or over round up. Input The input will contain one or more sets of data about potential labels. Each data set will consist of 4 non-negative integers, separated by one or more blanks, on a single line. The integers represent the number of calories, the number of grams of fat, the number of grams of carbohydrates, and the number of grams of protein, in that order. The number of calories will not exceed 10000, and the number of grams of any component will not exceed 1000. End of input is indicated by a line containing 4 zeroes. This line should not be processed. Output For each data set, print "yes" or "no" on its own line, indicating whether the given rounded values of the three nutrients can yield the given number of calories. Sample Input 250 12 31 5 250 13 31 5 122 10 10 0 0 0 0 0 Sample Output yes no no
Decompressing in a GIF 格式问题
Problem Description One well known method to compress image files is the Graphics Interchange Format (GIF) encoding, created by CompuServe in 1987. Here’s a simplified version applied to strings of alphabetic characters. Essential for this compression is a dictionary which assigns numeric encodings (we’ll use base 10 numbers for this problem) to different strings of characters. The dictionary is initialized with mappings for characters or substrings which may appear in the string. For example, if we expect to encounter all 26 letters of the alphabet, the dictionary will initially store the encodings (A, 00), (B, 01), (C, 02), . . . , (Z, 25). If we are compressing DNA data, the dictionary will initially store only 4 entries: (A, 0), (T, 1), (G, 2) and (C, 3). Note that the length of each initial encoding is the same for all entries (2 digits in the first example, and 1 digit in the second). The compression algorithm proceeds as follows: 1. Find the longest prefix of the uncompressed portion of the string which is in the dictionary, and replace it with its numeric encoding. 2. If the end of the string has not been reached, add a new mapping (s, n) to the dictionary, where s = the prefix just compressed plus the next character after it in the string, and n = the smallest number not yet used in the dictionary. For example, assume we started with the string ABABBAABB and a dictionary with just two entries, (A, 0) and (B, 1). The table below shows the steps in compressing the string. The final compressed string is 01234. There is only one other rule: the replacement strings used are always the size of the longest encoding in the dictionary at the time the replacement occurs. Thus, with the dictionary above, if the string to compress is long enough that an entry of the form (s, 10) is added to the dictionary, then from this point on all numerical replacement strings used in the compressed string must be expanded to 2 digits long (i.e., A will now be encoded as 00, B as 01, AB as 02, etc.); if an entry (s′, 100) is added to the dictionary, all replacements from this point forward will increase to 3 digits long, and so on. Thus, the longer string ABABBAABBAABAABAB will be encoded as 01234027301, not 0123402731. Try it! OK, now that you are experts at compressing, it’s time to relax and decompress! Input Each test case will consist of two lines. The first line will contain a string of digits to decompress. The second line will contain the initial dictionary used in the compression. This line will start with a positive integer n indicating the number of entries in the dictionary (1 ≤ n ≤ 100), followed by n alphabetic strings. The first of these will be paired with 0 in the dictionary (or 00 if n > 10), the second with 1, and so on. The last test case will be followed by a line containing a single 0. Output For each test case, output a single line containing the case number (using the format shown below) followed by the decompressed string. All input strings will have been legally compressed. Sample Input 01234 2 A B 01234027301 2 A B 02151120182729 26 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 21104 3 BA A C 01 2 JA VA 0 Sample Output Case 1: ABABBAABB Case 2: ABABBAABBAABAABAB Case 3: CPLUSPLUS Case 4: CAABAAA Case 5: JAVA
Doors and Penguins 的计算
Problem Description The organizers of the Annual Computing Meeting have invited a number of vendors to set up booths in a large exhibition hall during the meeting to showcase their latest products. As the vendors set up their booths at their assigned locations, they discovered that the organizers did not take into account an important fact---each vendor supports either the Doors operating system or the Penguin operating system, but not both. A vendor supporting one operating system does not want a booth next to one supporting another operating system. Unfortunately the booths have already been assigned and even set up. There is no time to reassign the booths or have them moved. To make matter worse, these vendors in fact do not even want to be in the same room with vendors supporting a different operating system. Luckily, the organizers found some portable partition screens to build a wall that can separate the two groups of vendors. They have enough material to build a wall of any length. The screens can only be used to build a straight wall. The organizers need your help to determine if it is possible to separate the two groups of vendors by a single straight wall built from the portable screens. The wall built must not touch any vendor booth (but it may be arbitrarily close to touching a booth). This will hopefully prevent one of the vendors from knocking the wall over accidentally. Input The input consists of a number of cases. Each case starts with 2 integers on a line separated by a single space: D and P, the number of vendors supporting the Doors and Penguins operating system, respectively (1 <= D, P <= 500). The next D lines specify the locations of the vendors supporting Doors. This is followed by P lines specifying the locations of the vendors supporting Penguins. The location of each vendor is specified by four positive integers: x1, y1, x2, y2. (x1, y1) specifies the coordinates of the southwest corner of the booth while (x2, y2) specifies the coordinates of the northeast corner. The coordinates satisfy x1 < x2 and y1 < y2. All booths are rectangular and have sides parallel to one of the compass directions. The coordinates of the southwest corner of the exhibition hall is (0,0) and the coordinates of the northeast corner is (15000, 15000). You may assume that all vendor booths are completely inside the exhibition hall and do not touch the walls of the hall. The booths do not overlap or touch each other. The end of input is indicated by D = P = 0. Output For each case, print the case number (starting from 1), followed by a colon and a space. Next, print the sentence: It is possible to separate the two groups of vendors. if it is possible to do so. Otherwise, print the sentence: It is not possible to separate the two groups of vendors. Print a blank line between consecutive cases. Sample Input 3 3 10 40 20 50 50 80 60 90 30 60 40 70 30 30 40 40 50 50 60 60 10 10 20 20 2 1 10 10 20 20 40 10 50 20 25 12 35 40 0 0 Sample Output Case 1: It is possible to separate the two groups of vendors. Case 2: It is not possible to separate the two groups of vendors.
The Partition of A Graph 程序的实现过程
Problem Description Simple enough, you’ll be given a simple undirected graph with n vertexes and m edges, try to divide this graph fits the following requirements: All edges are divided into several groups; only two edges exist in every group, and this two edges have common vertex. Your task is to figure out if such a partition exists. Input There are multiple test cases, for each test case: The first line contains two integers n (0<n<=1000) and m represent the number of vertexes and edges. The following m lines, each line contains two integers represent two endpoints of an edge. The vertexes are numbered from 1 to n. The input terminated when n=m=0. Output For each test case, output one line, if such a partition exists, print “Yes”, otherwise, print “No”. Sample Input 3 3 1 2 1 3 2 3 3 2 1 2 1 3 0 0 Sample Output No Yes
Average is not Fast Enough! 程序不太会
Problem Description A relay is a race for two or more teams of runners. Each member of a team runs one section of the race. Your task is to help to evaluate the results of a relay race. You have to process several teams. For each team you are given a list with the running times for every section of the race. You are to compute the average time per kilometer over the whole distance. That's easy, isn't it? So if you like the fun and challenge competing at this contest, perhaps you like a relay race, too. Students from Ulm participated e.g. at the "SOLA" relay in Zurich, Switzerland. For more information visit http://www.sola.asvz.ethz.ch/ after the contest is over. Input The first line of the input specifies the number of sections n followed by the total distance of the relay d in kilometers. You may safely assume that 1 <= n <= 20 and 0.0 < d < 200.0. Every following line gives information about one team: the team number t (an integer, right-justified in a field of width 3) is followed by the n results for each section, separated by a single space. These running times are given in the format "h:mm:ss" with integer numbers for the hours, minutes and seconds, respectively. In the special case of a runner being disqualified, the running time will be denoted by "-:--:--". Finally, the data on every line is terminated by a newline character. Input is terminated by EOF. Output For each team output exactly one line giving the team's number t right aligned in a field of width 3, and the average time for this team rounded to whole seconds in the format "m:ss". If at least one of the team's runners has been disqualified, output "-" instead. Adhere to the sample output for the exact format of presentation. Sample Input 2 12.5 5 0:23:21 0:25:01 42 0:23:32 -:--:-- 7 0:33:20 0:41:35 Sample Output 5: 3:52 min/km 42: - 7: 6:00 min/km
There is a war 是怎么写的
Problem Description There is a sea. There are N islands in the sea. There are some directional bridges connecting these islands. There is a country called Country One located in Island 1. There is another country called Country Another located in Island N. There is a war against Country Another, which launched by Country One. There is a strategy which can help Country Another to defend this war by destroying the bridges for the purpose of making Island 1 and Island n disconnected. There are some different destroying costs of the bridges. There is a prophet in Country Another who is clever enough to find the minimum total destroying costs to achieve the strategy. There is an architecture in Country One who is capable enough to rebuild a bridge to make it unbeatable or build a new invincible directional bridge between any two countries from the subset of island 2 to island n-1. There is not enough time for Country One, so it can only build one new bridge, or rebuild one existing bridge before the Country Another starts destroying, or do nothing if happy. There is a problem: Country One wants to maximize the minimum total destroying costs Country Another needed to achieve the strategy by making the best choice. Then what’s the maximum possible result? Input There are multiple cases in this problem. There is a line with an integer telling you the number of cases at the beginning. The are two numbers in the first line of every case, N(4<=N<=100) and M(0<=M<=n*(n-1)/2), indicating the number of islands and the number of bridges. There are M lines following, each one of which contains three integers a, b and c, with 1<=a, b<=N and 1<=c<=10000, meaning that there is a directional bridge from a to b with c being the destroying cost. There are no two lines containing the same a and b. Output There is one line with one integer for each test case, telling the maximun possible result. Sample Input 4 4 0 4 2 1 2 2 3 4 2 4 3 1 2 1 2 3 1 3 4 10 4 3 1 2 5 2 3 2 3 4 3 Sample Output 0 2 1 3
Guard 的设计的问题
Problem Description The Bluewater Security Company provides guards for clients with valuable possessions. Bluewater has found that clients are interested in having guards posted where they can see everything that is valuable merely by turning their heads, and also like guards to be posted particularly close to particularly valuable items. A sample site layout is shown above. Ignore the three black dots for now. Various locations are labeled and assigned values. For instance location A at coordinates (0,8) is the position of an item with value 4. Locations showing a value 0, like G, do not have a valuable item. The straight lines indicate corridors. For simplicity, corridors are modeled as line segments with 0 width. A guard at an intersection point of several corridors can see and therefore guard the items on each of the corridors. If Bluewater were contracted to supply 3 guards, they might choose to post them at the positions indicated with the small black dots. The guard not at an already labeled position is at (15.5, 6). To model the desire for guards to be closer to items of higher value, Bluewater calculates the risk to a valuable item to be the value of the item times the minimum distance to a guard that can see the item. Even if a guard is close to an item that is around a corner, that guard does not affect the risk to the item, since the guard cannot see around a corner. In the diagram shown, the risks to the items are A: 4x5=20, C: 4x2.5=10, D: 2x0=0, .... The largest risks are for H: 50x7.5=375 and I: 50x7.5=375, so the maximum risk to any one item is 375. With this site layout, no arrangement of 3 guards would provide a lower maximum risk, so this arrangement of 3 guards minimizes the maximum risk. Bluewater would like to be able to tell any client who requests a particular number of guards for a particular site layout, what the minimized maximum risk will be. Input The input will consist of one to sixteen data sets, followed by a line containing only 0. On each line the data will consist of blank separated tokens. The first line of a dataset contains integers p c g, where p is the number of points specified, c is the number of corridors, and g is the number of guards to be placed. Constraints are 1< p < 12; 0 < c < 12; 0 < g < 5. Next in the dataset are a total of p groups of four tokens, each consisting of a capital letter and three nonnegative integers L x y v indicating the point (x, y) with label L contains an item with value v. If p is no greater than 6, these groups will all be on one line. If p is greater than 6, then the seventh and further groups will be on the next line. Labels will be consecutive letters starting from A. All the numbers are less than 1000. Each of the points is unique. A value of 0 for v means there is no item of value there. The number of locations with items of value will be at least as large as the number of guards. The last line of a dataset contains c strings of letters, one for each corridor. For each corridor the letters are labels for points along the corridor, in order along the line segment from one end to the other, including both endpoints, all intersection points with other corridors, and all locations on the corridor with a valuable item. Each of the points given in the dataset will lie on at least one of the corridors. Output There is one line of output for each data set. If there are not enough guards supplied to be able to see all the valuables, the line is "too few guards". Otherwise the line is an unsigned number r rounded to two places beyond the decimal point, where r is the minimum value over all placements of g guards of the maximum "risk" to the valuables. Sample Input 11 5 3 A 0 8 4 B 5 8 0 C 14 8 4 D 21 8 2 E 25 8 1 F 5 22 1 G 5 20 0 H 11 12 50 I 20 0 50 J 19 10 5 K 25 4 5 ABCDE AG FGB GHCI JDK 11 5 2 A 0 8 4 B 5 8 0 C 14 8 4 D 21 8 2 E 25 8 1 F 5 22 1 G 5 20 0 H 11 12 50 I 20 0 50 J 19 10 5 K 25 4 5 ABCDE AG FGB GHCI JDK 11 5 1 A 0 8 4 B 5 8 0 C 14 8 4 D 21 8 2 E 25 8 1 F 5 22 1 G 5 20 0 H 11 12 50 I 20 0 50 J 19 10 5 K 25 4 5 ABCDE AG FGB GHCI JDK 11 5 4 A 0 8 4 B 5 8 0 C 14 8 4 D 21 8 2 E 25 8 1 F 5 22 1 G 5 20 0 H 11 12 50 I 20 0 50 J 19 10 5 K 25 4 5 ABCDE AG FGB GHCI JDK 3 3 1 A 0 0 50 B 0 3 60 C 4 0 20 AB CB CA 0 Sample Output 375.00 1250.00 too few guards 21.21 150.00
The Embarrassed Cryptographer
Problem Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of users, which is now in use in his company. The cryptographic keys are created from the product of two primes, and are believed to be secure because there is no known method for factoring such a product effectively. What Odd Even did not think of, was that both factors in a key should be large, not just their product. It is now possible that some of the users of the system have weak keys. In a desperate attempt not to be fired, Odd Even secretly goes through all the users keys, to check if they are strong enough. He uses his very poweful Atari, and is especially careful when checking his boss' key. Input The input consists of no more than 20 test cases. Each test case is a line with the integers 4 <= K <= 10100 and 2 <= L <= 106. K is the key itself, a product of two primes. L is the wanted minimum size of the factors in the key. The input set is terminated by a case where K = 0 and L = 0. Output For each number K, if one of its factors are strictly less than the required L, your program should output "BAD p", where p is the smallest factor in K. Otherwise, it should output "GOOD". Cases should be separated by a line-break. Sample Input 143 10 143 20 667 20 667 30 2573 30 2573 40 0 0 Sample Output GOOD BAD 11 GOOD BAD 23 GOOD BAD 31
There is a war 的正确写法
Problem Description There is a sea. There are N islands in the sea. There are some directional bridges connecting these islands. There is a country called Country One located in Island 1. There is another country called Country Another located in Island N. There is a war against Country Another, which launched by Country One. There is a strategy which can help Country Another to defend this war by destroying the bridges for the purpose of making Island 1 and Island n disconnected. There are some different destroying costs of the bridges. There is a prophet in Country Another who is clever enough to find the minimum total destroying costs to achieve the strategy. There is an architecture in Country One who is capable enough to rebuild a bridge to make it unbeatable or build a new invincible directional bridge between any two countries from the subset of island 2 to island n-1. There is not enough time for Country One, so it can only build one new bridge, or rebuild one existing bridge before the Country Another starts destroying, or do nothing if happy. There is a problem: Country One wants to maximize the minimum total destroying costs Country Another needed to achieve the strategy by making the best choice. Then what’s the maximum possible result? Input There are multiple cases in this problem. There is a line with an integer telling you the number of cases at the beginning. The are two numbers in the first line of every case, N(4<=N<=100) and M(0<=M<=n*(n-1)/2), indicating the number of islands and the number of bridges. There are M lines following, each one of which contains three integers a, b and c, with 1<=a, b<=N and 1<=c<=10000, meaning that there is a directional bridge from a to b with c being the destroying cost. There are no two lines containing the same a and b. Output There is one line with one integer for each test case, telling the maximun possible result. Sample Input 4 4 0 4 2 1 2 2 3 4 2 4 3 1 2 1 2 3 1 3 4 10 4 3 1 2 5 2 3 2 3 4 3 Sample Output 0 2 1 3
Assignment Tools 工具问题
Problem Description In Valentine’s Day, lovers usually send gifts to their GF or BF. To express their sincerity, they choose DIY. Small JH want to make a surprise to his GF, so he finds a shop named “DIY Space”. But there are so many people scramble for tools to make their gifts. To solve the problem, the boss makes a rule: 1.You will not regain the tool until you can complete all things what you need to do.(If someone has all tools he needs, he will complete immediately. Otherwise, he can’t do anything) 2.If the boss has enough tools he will give you when you need tools. 3.You don't have to queue up. Small JH should wait until all people leave, because he needs all tools. People have their tools and never return before completing their tasks. Sometimes it has a state: the boss has no tools any more and everyone can’t get enough tools. Please tell him whether he should wait. Input The input consist of several cases, please deal with till the end of file. Each case contains two integers N and M (0 < N, M <= 100), representing there are N kinds of tools and M people. Second line there are N integers, N(i) means the boss own Ni number of ith tool(equal to the number of tools Small JH need).Then follow M lines, each consisting N integers, the number in ith row and jth column means the amount of the jth tools that the ith people need. After it there also M lines, each line has N integers too, the number in ith row and jth column means this amount of jth tools have been allotted to the ith people. The total number of ith tool that all people own will not bigger than boss own at first. Output Please print “Yes” if Small JH can wait the end, or print “No” if he can’t; Sample Input 2 2 10 11 9 8 5 8 2 3 3 5 2 2 10 10 9 8 5 8 2 3 3 5 Sample Output Yes No
Colliding Traffic 怎么来做到的
Problem Description For a boat on a small, constrained body of water, other traffic can be a major hazard. The more traffic there is in the same area, the higher the risk of a collision. Your job is to monitor traffic and help detect likely collisions before they occur. You have sensors to detect the position, direction, and speed of each boat. Assuming the direction and speed remain constant, your task is to determine whether any of the boats will collide. Two boats are considered to collide if they come within a given distance of each other. Input The first line of each test chunk contains a single integer c, the number of test cases to follow. Each test case starts with a line containing two numbers, n, the number of boats, and r, the collision distance. Two boats are considered to collide if they come within r metres of each other. There will be no more than 1000 boats. Each boat is identified by a line containing four numbers x, y, d, s. The numbers x and y give the current position of the boat as a distance east and north, respectively, from a common origin, and will be between -1000 and 1000, inclusive. The lake is small enough that we can model it as a flat surface. The number d gives the direction in which the boat is heading in degrees clockwise from north (so east is 90 degrees). The number s gives the speed of the boat in metres per second, and will be between 0.001 and 1000. Note that r, x, y, d, and s are not necessarily integers. The input data will be such that the answer will not change if any of the numbers x, y, d and s are changed by 10^-6 or less. Please process to the end of the data file. Output For each test case, output a line containing a single integer, the number of seconds, rounded to the nearest second, before any of the boats come within r metres of each other. If none of the boats ever collide, output the line: No collision. Sample Input 2 2 5 0 0 90 1 10 10 180 1 2 10 0 0 0 0 8 8 270 1 2 2 5 0 0 90 1 10 10 180 1 2 10 0 0 0 0 8 8 270 1 Sample Output 6 2 6 2
Porcelain Exhibitions 是怎么设计的呢
Problem Description Recently, the Chinese government is going to hold a porcelain exhibition in every province. For fascinating citizens, each exhibition should put at least MIN_K porcelains on show. And by the restriction of conditions, at most MAX_K porcelains can be shown in an exhibition. The number of porcelains in a province is in direct proportion to the area of that province. So some small provinces may don't have enough porcelains, and some big provinces may have more porcelains than it can show(having too much porcelains is not a problem for holding an exhibition, just don’t show some of them). The government decides to transport some porcelains between provinces so that every province can hold an exhibition. Because of the limitation of traffic, the amount of porcelains passing a boundary between two provinces is limited. So the government asks you to write a program to manage the transportation. The map of China can be seen as a connected planar graph embedded on a plane. Each face of the graph represents a province. This graph has N vertices and M edges. A vertex of the graph is also a point on the map, and an edge is also a line segment connecting two points, meaning a boundary between two provinces. Input The input will consist of multiply test cases. For each case, The first line contains five positive integers --- above mentioned N, M, MIN_K,MAX_K and P( N <= 1000,M <= 10000, MIN_K < MAX_K) . P means that if the area of a province is A, then there are A×P porcelains in that province. P is guaranteed to be even so that the amount of porcelains in each province will be a positive integer. The next N lines, each gives two integer x, y, representing the coordinate of a vertex(Vertexes have distinct coordinates). The vertexes are numbered from 0 to N-1 and the coordinates are given in the order of vertex No. The next M lines, each gives three integers u,v, and w. It means that there is an edge connecting vertex u and vertex v. The edge is also a boundary between two provinces. w means that the boundary can’t let more than w porcelains to pass through. (w for the boundary of China is 0, and boundaries don't overlap). The number of province is less than 2000. Unsigned int is enough for this problem. The input ends with 0 0 0 0 0. Output For each test case, print one integer in a line representing the maximal number of porcelains can be exhibited in whole country. If one or more province can’t hold an exhibition, print -1. Sample Input 8 9 5 8 2 0 0 0 3 3 3 3 0 1 1 1 2 2 2 2 1 0 1 0 1 2 0 2 3 0 3 0 0 4 5 1 5 6 1 6 7 1 7 4 1 0 4 1 8 9 7 8 2 0 0 0 3 3 3 3 0 1 1 1 2 2 2 2 1 0 1 0 1 2 0 2 3 0 3 0 0 4 5 1 5 6 1 6 7 1 7 4 1 0 4 1 0 0 0 0 0 Sample Output 14 -1

Java学习的正确打开方式

linux系列之常用运维命令整理笔录

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。 1. for - else 什么？不是 if 和 else 才

2019年11月中国大陆编程语言排行榜
2019年11月2日，我统计了某招聘网站，获得有效程序员招聘数据9万条。针对招聘信息，提取编程语言关键字，并统计如下： 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7

SQL-小白最佳入门sql查询一

【图解经典算法题】如何用一行代码解决约瑟夫环问题

“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

IT界知名的程序员曾说：对于那些月薪三万以下，自称IT工程师的码农们，其实我们从来没有把他们归为我们IT工程师的队伍。他们虽然总是以IT工程师自居，但只是他们一厢情愿罢了。 此话一出，不知激起了多少(码农)程序员的愤怒，却又无可奈何，于是码农问程序员。 码农：你知道get和post请求到底有什么区别？ 程序员：你看这篇就知道了。 码农：你月薪三万了？ 程序员：嗯。 码农：你是怎么做到的? 程序员：
《程序人生》系列-这个程序员只用了20行代码就拿了冠军

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1

【技巧总结】位运算装逼指南

8年经验面试官详解 Java 面试秘诀
作者 | 胡书敏 责编 | 刘静 出品 | CSDN（ID：CSDNnews） 本人目前在一家知名外企担任架构师，而且最近八年来，在多家外企和互联网公司担任Java技术面试官，前后累计面试了有两三百位候选人。在本文里，就将结合本人的面试经验，针对Java初学者、Java初级开发和Java开发，给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实

1.两种思维方式在求职面试中，经常会考察这种问题：北京有多少量特斯拉汽车？ 某胡同口的煎饼摊一年能卖出多少个煎饼？ 深圳有多少个产品经理？ 一辆公交车里能装下多少个乒乓球？ 一