 Give Me an E

Everyone knows that the letter "E" is the most frequent letr in the English language. In fact, there are one hundred sixteen E's on this very page ... no, make tha one hundred twenty one. Indeed, when spelling out integers it is interesting to see which ones do NOT use the letter "E". For example 60 (six thousand thirty) doesn't. Nor does 4002064 (four millon two thousand sixty four).
It turns out that 6030 is the 64th positive integer that does not use an "E" when spelled out a 4002064 is the 838th such number. Your job is to find the nth such number.
Note: 1,001,001,001,001,001,001,001,001,000 is "one ocillion, one septillion, one sextillion, one quintillion, one quadrillion, one trillion, one billion, one million, one thousand". (Whew!)
Input
The input will consist of multiple test cases. Each input case will consist of one positive integer n (less than 2^31 ) on a line. A 0 indicates endofinput. (There will be no commas in the input.)
Output
For each input n you will print, with appropriate commas, the nth positive integer whose spelling does not use an "E". You may assume that all answers are less than 10^28.
Sample Input
1
10
838
0Sample Output
2
44
4,002,064
Give Me an E _course
20170530Problem Description Everyone knows that the letter “E” is the most frequent letter in the English language. In fact, there are one hundred sixteen E’s on this very page ... no, make that one hundred twenty one. Indeed, when spelling out integers it is interesting to see which ones do NOT use the letter “E”. For example 6030 (six thousand thirty) doesn’t. Nor does 4002064 (four million two thousand sixty four). It turns out that 6030 is the 64th positive integer that does not use an “E” when spelled out and 4002064 is the 838th such number. Your job is to find the nth such number. Note: 1,001,001,001,001,001,001,001,001,000 is “one octillion, one septillion, one sextillion, one quintillion, one quadrillion, one trillion, one billion, one million, one thousand”. (Whew!) Input The input file will consist of multiple test cases. Each input case will consist of one positive integer n (less than 231) on a line. A 0 indicates endofinput. (There will be no commas in the input.) Output For each input n you will print, with appropriate commas, the nth positive integer whose spelling does not use an “E”. You may assume that all answers are less than 1028. Sample Input 1 10 838 0 Sample Output 2 44 4,002,064
Calories from Fat _course
20171016Description Fat contains about 9 Calories/g of food energy. Protein, sugar, and starch contain about 4 Calories/g, while alcohol contains about 7 Calories/g. Although many people consume more than 50% of their total Calories as fat, most dieticians recommend that this proportion should be 30% or less. For example, in the Nutrition Facts label to the right, we see that 3g of fat is 5% of the recommended daily intake based on a 2,000 calorie diet. A quick calculation reveals that the recommended daily intake of fat is therefore 60g; that is, 540 Calories or 27% Calories from fat. Others recommend radically different amounts of fat. Dean Ornish, for example, suggests that less than 10% of total caloric intake should be fat. On the other hand, Robert Atkins recommends the elimination of all carbohydrate with no restriction on fat. It has been estimated that the average Atkins dieter consumes 61% of Calories from fat. From a record of food eaten in one day, you are to compute the percent Calories from fat. The record consists of one line of input per food item, giving the quantity of fat, protein, sugar, starch and alcohol in each. Each quantity is an integer followed by a unit, which will be one of: g (grams), C (Calories), or % (percent Calories). Percentages will be between 0 and 99. At least one of the ingredients will be given as a nonzero quantity of grams or Calories (not percent Calories). Input Input will consist of several test cases. Each test case will have one or more lines as described above. Each test case will be terminated by a line containing ''. An additional line containing '' will follow the last test case. Output For each test case, print percent Calories from fat, rounded to the nearest integer. Sample Input 3g 10g 10% 0g 0g 55% 100C 0% 0g 30g  25g 0g 0g 0g 0g  1g 15% 20% 30% 1C   Sample Output 53% 100% 32%
poker card game _course
20171015Description Suppose you are given many poker cards. As you have already known, each card has points ranging from 1 to 13. Using these poker cards, you need to play a game on the cardboard in Figure 1. The game begins with a place called START. From START, you can walk to left or right to a rectangular box. Each box is labeled with an integer, which is the distance to START. ![](http://poj.org/images/1339_1.jpg) Figure 1: The poker card game cardboard. To place poker cards on these boxes, you must follow the rules below: (1) If you put a card with n points on a box labeled i , you got (n ∗ i) points. (2) Once you place a card on a box b, you block the paths to the boxes behind b. For example, in Figure 2, a player places a queen on the right box of distance 1, he gets 1 ∗ 12 points but the queen also blocks the paths to boxes behind it; i.e., it is not allowed to put cards on boxes behind it anymore. ![](http://poj.org/images/1339_2.jpg) Figure 2: Placing a queen. Your goal: Given a number of poker cards, find a way to place them so that you will get the minimum points. For example, suppose you have 3 cards 5, 10, and K. To get the minimum points, you can place cards like Figure 3, where the total points are 1 * 13 + 2 * 5 + 2 * 10 = 43. ![](http://poj.org/images/1339_3.jpg) Figure 3: An example to place cards. Input The first line of the input file contains an integer n, n <= 10, which represents the number of test cases. In each test case, it begins with an integer m, m <= 100000, which represents the number of poker cards. Next, each card represented by its number are listed consecutively. Note that, the numbers of ace, 2, 3, ..., K are given by integers 1, 2, 3, ..., 13, respectively. The final minimum point in each test case is less than 5000000. Output List the minimum points of each test case line by line. Sample Input 3 3 5 10 13 4 3 4 5 5 5 7 7 10 11 13 Sample Output 43 34 110
Magic Bitstrings _course
20171016Description A bitstring, whose length is one less than a prime, might be magic. 1001 is one such string. In order to see the magic in the string let us append a nonbit x to it, regard the new thingy as a cyclic string, and make this square matrix of bits each bit 1001 every 2nd bit 0110 every 3rd bit 0110 every 4th bit 1001 This matrix has the same number of rows as the length of the original bitstring. The mth row of the matrix has every mth bit of the original string starting with the mth bit. Because the enlarged thingy has prime length, the appended x never gets used. If each row of the matrix is either the original bitstring or its complement, the original bitstring is magic. Input Each line of input (except last) contains a prime number p <= 100000. The last line contains 0 and this line should not be processed. Output For each prime number from the input produce one line of output containing the lexicographically smallest, nonconstant magic bitstring of length p1, if such a string exists, otherwise output Impossible. Sample Input 5 3 17 47 2 79 0 Sample Output 0110 01 0010111001110100 0000100001101010001101100100111010100111101111 Impossible 001001100001011010000001001111001110101010100011000011011111101001011110011011
Shredding Company _course
20171017Description You have just been put in charge of developing a new shredder for the Shredding Company Although a "normal" shredder would just shred sheets of paper into little pieces so that the contents would become unreadable, this new shredder needs to have the following unusual basic characteristics. 1.The shredder takes as input a target number and a sheet of paper with a number written on it. 2.It shreds (or cuts) the sheet into pieces each of which has one or more digits on it. 3.The sum of the numbers written on each piece is the closest possible number to the target number, without going over it. For example, suppose that the target number is 50, and the sheet of paper has the number 12346. The shredder would cut the sheet into four pieces, where one piece has 1, another has 2, the third has 34, and the fourth has 6. This is because their sum 43 (= 1 + 2 + 34 + 6) is closest to the target number 50 of all possible combinations without going over 50. For example, a combination where the pieces are 1, 23, 4, and 6 is not valid, because the sum of this combination 34 (= 1 + 23 + 4 + 6) is less than the above combination's 43. The combination of 12, 34, and 6 is not valid either, because the sum 52 (= 12 + 34 + 6) is greater than the target number of 50. ![](http://poj.org/images/1416_1.jpg) Figure 1. Shredding a sheet of paper having the number 12346 when the target number is 50 There are also three special rules : 1.If the target number is the same as the number on the sheet of paper, then the paper is not cut. For example, if the target number is 100 and the number on the sheet of paper is also 100, then the paper is not cut. 2.If it is not possible to make any combination whose sum is less than or equal to the target number, then error is printed on a display. For example, if the target number is 1 and the number on the sheet of paper is 123, it is not possible to make any valid combination, as the combination with the smallest possible sum is 1, 2, 3. The sum for this combination is 6, which is greater than the target number, and thus error is printed. 3.If there is more than one possible combination where the sum is closest to the target number without going over it, then rejected is printed on a display. For example, if the target number is 15, and the number on the sheet of paper is 111, then there are two possible combinations with the highest possible sum of 12: (a) 1 and 11 and (b) 11 and 1; thus rejected is printed. In order to develop such a shredder, you have decided to first make a simple program that would simulate the above characteristics and rules. Given two numbers, where the first is the target number and the second is the number on the sheet of paper to be shredded, you need to figure out how the shredder should "cut up" the second number. Input The input consists of several test cases, each on one line, as follows : tl num1 t2 num2 ... tn numn 0 0 Each test case consists of the following two positive integers, which are separated by one space : (1) the first integer (ti above) is the target number, (2) the second integer (numi above) is the number that is on the paper to be shredded. Neither integers may have a 0 as the first digit, e.g., 123 is allowed but 0123 is not. You may assume that both integers are at most 6 digits in length. A line consisting of two zeros signals the end of the input. Output For each test case in the input, the corresponding output takes one of the following three types : sum part1 part2 ... rejected error In the first type, partj and sum have the following meaning : 1.Each partj is a number on one piece of shredded paper. The order of partj corresponds to the order of the original digits on the sheet of paper. 2.sum is the sum of the numbers after being shredded, i.e., sum = part1 + part2 +... Each number should be separated by one space. The message error is printed if it is not possible to make any combination, and rejected if there is more than one possible combination. No extra characters including spaces are allowed at the beginning of each line, nor at the end of each line. Sample Input 50 12346 376 144139 927438 927438 18 3312 9 3142 25 1299 111 33333 103 862150 6 1104 0 0 Sample Output 43 1 2 34 6 283 144 139 927438 927438 18 3 3 12 error 21 1 2 9 9 rejected 103 86 2 15 0 rejected
Map of Ninja House _course
20171017Description An old document says that a Ninja House in Kanazawa City was in fact a defensive fortress, which was designed like a maze. Its rooms were connected by hidden doors in a complicated manner, so that any invader would become lost. Each room has at least two doors. The Ninja House can be modeled by a graph, as shown in Figure 1. A circle represents a room. Each line connecting two circles represents a door between two rooms. I decided to draw a map, since no map was available. Your mission is to help me draw a map from the record of my exploration. I started exploring by entering a single entrance that was open to the outside. The path I walked is schematically shown in Figure 2, by a line with arrows. The rules for moving between rooms are described below. After entering a room, I first open the rightmost door and move to the next room. However, if the next room has already been visited, I close the door without entering, and open the next rightmost door, and so on. When I have inspected all the doors of a room, I go back through the door I used to enter the room. I have a counter with me to memorize the distance from the first room. The counter is incremented when I enter a new room, and decremented when I go back from a room. In Figure 2, each number in parentheses is the value of the counter when I have entered the room, i.e., the distance from the first room. In contrast, the numbers not in parentheses represent the order of my visit. I take a record of my exploration. Every time I open a door, I record a single number, according to the following rules. 1. If the opposite side of the door is a new room, I record the number of doors in that room, which is a positive number. 2. If it is an already visited room, say R, I record "the distance of R from the first room" minus "the distance of the current room from the first room", which is a negative number. In the example shown in Figure 2, as the first room has three doors connecting other rooms, I initially record "3". Then when I move to the second, third, and fourth rooms, which all have three doors, I append "3 3 3" to the record. When I skip the entry from the fOurth room to the first room, the distance difference "3" (minus three) will be appended, and so on. So, when I finish this exploration, its record is a sequence of numbers "3 3 3 3 3 3 2 5 3 2 5 3". There are several dozens of Ninja Houses in the city. Given a sequence of numbers for each of these houses, you should produce a graph for each house. Input The first line of the input is a single integer n, indicating the number of records of Ninja Houses I have visited. You can assume that n is less than 100. Each of the following n records consists of numbers recorded on one exploration and a zero as a terminator. Each record consists of one or more lines whose lengths are less than 1000 characters. Each number is delimited by a space or a newline. You can assume that the number of rooms for each Ninja House is less than 100, and the number of doors in each room is less than 100. Output For each Ninja House of m rooms, the output should consist of m lines. The ith line of each such m lines should look as follows: i r(1) r(2)... r(ki), where r(1),... , r(ki), should be rooms adjoining room i, and ki should be the number of doors in room i. Numbers should be separated by exactly one space character. The rooms should be numbered from 1 in visited order. r(1), r(2),..., r(ki), should be in ascending order. Note that the room i may be connected to another room through more than one door. In this case, that room number should appear in r(1),...,r(ki), as many times as it is connected by different doors. Sample Input 2 3 3 3 3 3 3 2 5 3 2 5 3 0 3 5 4 2 4 3 2 2 1 0 Sample Output 1 2 4 6 2 1 3 8 3 2 4 7 4 1 3 5 5 4 6 7 6 1 5 7 3 5 8 8 2 7 1 2 3 4 2 1 3 3 4 4 3 1 2 2 4 4 1 2 2 3
Up and Down Sequences _course
20171013Description The quality of pseudo randomnumber generators used in some computations, especially simulation, is a significant issue. Proposed generation algorithms are subjected to many tests to establish their quality, or, more usually, their lack of it. One of the common tests is the run test. In this test, sequences are tested for ``runs up" and ``runs down." We will examine series of data values for the ``Up" and ``Down" sequences each series contains. Within a series, an ``Up" sequence continues as long as each datavalue received is not less than the previous datavalue. An ``Up" sequence terminates when a datavalue received is less than the previous datavalue received. A ``Down" sequence continues as long as each datavalue received is not greater than the previous datavalue. A ``Down" sequence terminates when a datavalue received is greater than the previous datavalue received. An ``Up" sequence can be initiated by the termination of a ``Down" sequence and vice versa. (Sequences initiated in this manner have length one at this initiation point.) All the initial datavalues are part of an ``Up" sequence, and contribute to its length, if the first deviation of the datavalues is upwards. All the initial datavalues are part of a ``Down" sequence, and contribute to its length, if the first deviation of the datavalues is downwards. If the datavalues received don't allow classification as either an ``Up" or a ``Down" sequence, the data should be considered to have neither sequence. Find the average length of both the ``Up" and the ``Down" sequences encountered for each input line in the data file. Report these average lengths as each input line is processed. Input Each of the separate series to be examined is contained on a single line of input. Each series to be analyzed consists of at least one and no more than 30 unsigned, nonzero integers. Each integer in a series has at least one digit and no more than four digits. The integers are separated from each other by a single blank character. Each of the series will be terminated by a single zero (0) digit. This terminator should not be considered as being part of the series being analyzed. The set of series to be analyzed is terminated by a single zero (0) digit as the input on a line. This terminator should not be considered to be a series, and no output should be produced in response to its encounter. Output A line with two real values is to be emitted for each input data set encountered. It must begin with the message ``Nr values = N: ", where N is the number of input data in the line; and then to continue with the average values for runs. First, the average ``Up" run length, then the average ``Down" run length. Separate these values with a space. Answers must be rounded to six digits after the decimal point. Sample Input 1 2 3 0 3 2 1 0 1 2 3 2 1 0 2 2 2 2 3 0 4 4 4 4 3 0 4 4 4 3 3 3 3 0 4 4 4 3 3 3 4 0 5 5 5 5 0 1 2 3 2 3 4 5 0 0 Sample Output Nr values = 3: 2.000000 0.000000 Nr values = 3: 0.000000 2.000000 Nr values = 5: 2.000000 2.000000 Nr values = 5: 4.000000 0.000000 Nr values = 5: 0.000000 4.000000 Nr values = 7: 0.000000 6.000000 Nr values = 7: 1.000000 5.000000 Nr values = 4: 0.000000 0.000000 Nr values = 7: 2.500000 1.000000
Big Number _course
20170127Description As we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a program to calculate A mod B. To make the problem easier, I promise that B will be smaller than 100000. Is it too hard? No, I work it out in 10 minutes, and my program contains less than 25 lines. Input The input contains several test cases. Each test case consists of two positive integers A and B. The length of A will not exceed 1000, and B will be smaller than 100000. Process to the end of file. Output For each test case, you have to ouput the result of A mod B. Sample Input 2 3 12 7 152455856554521 3250 Sample Output 2 5 1521
To Bet or Not To Bet _course
20171017Description Alexander Charles McMillan loves to gamble, and during his last trip to the casino he ran across a new game. It is played on a linear sequence of squares as shown below. ![](http://poj.org/images/1644_1.jpg) A chip is initially placed on the Start square. The player then tries to move the chip to the End square through a series of turns, at which point the game ends. In each turn a coin is fl ipped: if the coin is heads the chip is moved one square to the right and if the coin is tails the chip is moved two squares to the right (unless the chip is one square away from the End square, in which case it just moves to the End square). At that point, any instruction on the square the coin lands on must be followed. Each instruction is one of the following: 1. Move right n squares (where n is some positive integer) 2. Move left n squares (where n is some positive integer) 3. Lose a turn 4. No instruction After following the instruction, the turn ends and a new one begins. Note that the chip only follows the instruction on the square it lands on after the coin flip. If, for example, the chip lands on a square that instructs it to move 3 spaces to the left, the move is made, but the instruction on the resulting square is ignored and the turn ends. Gambling for this game proceeds as follows: given a board layout and an integer T, you must wager whether or not you think the game will end within T turns. After losing his shirt and several other articles of clothing, Alexander has decided he needs professional helpnot in beating his gambling addiction, but in writing a program to help decide how to bet in this game. Input Input will consist of multiple problem instances. The first line will consist of an integer n indicating the number of problem instances. Each instance will consist of two lines: the first will contain two integers m and T (1 <= m <= 50, 1 <= T <= 40), where m is the size of the board excluding the Start and End squares, and T is the target number of turns. The next line will contain instructions for each of the m interior squares on the board. Instructions for the squares will be separated by a single space, and a square instruction will be one of the following: +n, n, L or 0 (the digit zero). The first indicates a right move of n squares, the second a left move of n squares, the third a loseaturn square, and the fourth indicates no instruction for the square. No right or left move will ever move you off the board. Output Output for each problem instance will consist of one line, either Bet for. x.xxxx if you think that there is a greater than 50% chance that the game will end in T or fewer turns, or Bet against. x.xxxx if you think there is a less than 50% chance that the game will end in T or fewer turns, or Push. 0.5000 otherwise, where x.xxxx is the probability of the game ending in T or fewer turns rounded to 4 decimal places. (Note that due to rounding the calculated probability for display, a probability of 0.5000 may appear after the Bet for. or Bet against. message.) Sample Input 5 4 4 0 0 0 0 3 3 0 1 L 3 4 0 1 L 3 5 0 1 L 10 20 +1 0 0 1 L L 0 +3 7 0 Sample Output Bet for. 0.9375 Bet against. 0.0000 Push. 0.5000 Bet for. 0.7500 Bet for. 0.8954
Refrigerator Magnets _course
20171024问题描述 : Like many families with small children, my family’s refrigerator is adorned with a set of alphabet magnets: 26 separate magnets, each containing one letter of the alphabet. These magnets can be rearranged to create words and phrases. I feel it is my parental duty to use these magnets to create messages that are witty and insightful, yet at the same time caring and supportive. Unfortunately, I am somewhat hindered in this task by the fact that I can only make phrases that use each letter once. For example, a nice inspiring message to leave for the children might be, “I LOVE YOU.” Unfortunately, I cannot make this message using my magnets because it requires two letter "O"s. I can, however, make the message, “I LOVE MUSTARD.” Admittedly this message isn’t as meaningful, but it does manage to not use any letters more than once. You are to write a program that will look at a list of possible phrases and report which phrases can be written using refrigerator magnets. 输入: The input will consist of one or more lines, ending with a line that contains only the word “END”. Each line will be 60 characters or less, and will consist of one or more words separated by a single space each, with words using only uppercase letters (A�1�7CZ). There will not be any leading or trailing whitespace, and there will not be any blank lines. 输出: The input will consist of one or more lines, ending with a line that contains only the word “END”. Each line will be 60 characters or less, and will consist of one or more words separated by a single space each, with words using only uppercase letters (A�1�7CZ). There will not be any leading or trailing whitespace, and there will not be any blank lines. 样例输入: I LOVE YOU I LOVE MUSTARD HAPPY BIRTHDAY GLAD U BORN SMILE IMAGINE WHATS UP DOC HAVE A NICE DAY END 样例输出: I LOVE MUSTARD GLAD U BORN SMILE WHATS UP DOC
Generalized Palindromic Number _course
20170902A number that will be the same when it is written forwards or backwards is known as a palindromic number. For example, 1234321 is a palindromic number. We call a number generalized palindromic number, if after merging all the consecutive same digits, the resulting number is a palindromic number. For example, 122111 is a generalized palindromic number. Because after merging, 122111 turns into 121 which is a palindromic number. Now you are given a positive integer N, please find the largest generalized palindromic number less than N. Input There are multiple test cases. The first line of input contains an integer T (about 5000) indicating the number of test cases. For each test case: There is only one integer N (1 <= N <= 1018). Output For each test case, output the largest generalized palindromic number less than N. Sample Input 4 12 123 1224 1122 Sample Output 11 121 1221 1121
Elevator _course
20170423The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop. For a given request list, you are to compute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not have to return to the ground floor when the requests are fulfilled. Input There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed. Output Print the total time on a single line for each test case. Sample Input 1 2 3 2 3 1 0 Sample Output 17 41
Housing Complexes _course
20171017Description The Ministry of housing is planning a huge construction project of several housing complexes. Each complex includes several apartments to be sold to government employees at reasonable prices. The ministry has located several big m*n pieces of land that can potentially be used for such construction project; one complex in each land. The lands are all rectangular, each with m*n number of 1*1 square blocks. All housing complexes are h*w rectangles covering exactly h*w blocks of each containing land. The problem is that there are originally some old buildings, each covering exactly one block of a land, making it impossible to locate enough free space for all the complexes in order to start the project. Therefore, the ministry has to buy some of these buildings, and demolish them to free the needed space. The old buildings belong to certain number of people. These people are angry of the possibility that their building may be bought and demolished, especially because the government usually pays much less for their buildings compared to the open market prices. In response to the protests, the ministry announces a "fair" decision that if it buys some buildings in one land, it will only choose those that belong only to one owner, and will buy all of them at reasonable price. And, it promises not to buy buildings belonging to the same owner in other lands. Note that with this constraint, there may be some lands in which building a complex is impossible. Trying to keep its promises, the ministry has asked you to write a program to see how many housing complexes can be constructed at most with these conditions. 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 contains five integers k (1 <= k <= 30), the number of lands, m and n (1 <= m, n <= 50), the number of rows and columns in each land respectively, and h and w (1 <= h, w <= 50), the number of rows and columns a complex occupies. After the first line, there are k*m lines in the input, representing k lands, each by an m*n matrix. Each line contains a string of length n with no leading or trailing spaces. Each character in the strings represents a block in the land and may be an upper case alphabetic character 'A'..'Z', indicating the owner of the block, or the character '0' indicating the block is free. Output There should be one line per test case containing the maximum number of housing complexes that can be constructed for that test case. Sample Input 2 3 4 3 3 2 A0B 000 0A0 00B AA0 00B 0B0 000 A0A 000 B00 B00 3 4 3 3 2 A0B 000 0A0 00B AA0 00B 0B0 000 A0A 000 0B0 B00 Sample Output 3 2
Mincost _course
20170406The cost of taking a taxi in Hangzhou is not a constant for each kilometer you travel: the first 4 kilometers costs 10 yuan (yuan is the monetary unit in China), even if you don't finish it; the next 4 kilometers costs 2 yuan each and the price for the rest of the trip is 2.4 yuan per kilometer; the last part of the trip is regarded as 1 kilometer even if it's shorter. A traveller may reduce the cost by reseting the meter at the middle of the trip if used wisely. For example, if the trip is 16 kilometers, he should cut it into two parts with the same length, each half will cost 18 yuan, with an overall cost of 36, less than the original price of 37.2. Now, given the length of the trip, find the minimum cost. Input The input contains several cases, each has one positive integer in a seperate line, representing the length of the trip. All input data are less than 10000000. Proceed until a case with zero, which should be ignored. Output For each case, output the minimum cost, leave one digit after decimal point if NECESSARY. Sample Input 3 9 16 0 Sample Output 10 20.4 36
Repair the Roof _course
20170422Poor Windprayer. This time a terrible hurricane has seriously damaged the roof of his house. Now he wants to repair it with minimum cost. You can consider the roof as a N by M rectangle, each grid is associated with a damage value, indicating the degree of damage of that grid (a grid is all right and shouldn't to be repaired if the damage value is 0). Only 1*2 and 2*1 woods are available to repair the roof, and for some visual reason Windprayer will buy woods of same spec and same price. A piece of wood can be used to repair the roof if the price of it is not less than the sum of damage value of the two grids it covers. Input: The input file contain several test cases, each test case begin with two integers N and M (2 <= N, M <= 50), which is size of the roof. N lines follow, each with M nonnegative integer not greater than 10000000, showing the damage value. Output: For each test case, if it's impossible to repair the roof, output "pat", otherwise, output the minimum cost in the first line, then in each of the following lines, output "(X1,Y1) (X2,Y2)", where (X1, Y1) and (X2, Y2) are positions that piece of wood will cover. Sample input: 2 2 1 2 3 4 2 2 0 1 1 1 Sample output: 12 (0,1) (1,1) (1,0) (0,0) pat
Huffman Trees _course
20170228A relatively simple method for compressing data works by creating a socalled Huffman tree for a file and using it to compress and decompress the data it contains. For most applications, binary Huffman trees are used (i.e., each node is either a leaf or has exactly two subnodes). One can, however, construct Huffman trees with an arbitrary number of subtrees (i.e, ternary or, in general, Nary trees). A Huffman tree for a file containing Z different characters has Z leaves. The path from the root to a leaf that represents a certain character determines its encoding; each step towards the leaf determines an encoding character (which can be 0, 1, ..., (N1)). By placing oftenoccurring characters closer to the root, and less often occurring characters further away from the root, the desirable compression is achieved. Strictly speaking, such a tree is a Huffman tree only if the resulting encoding takes the minimal number of Nary symbols to encode the complete file. For this problem, we only consider trees where each node is either an internal node, or a leaf encoding a character; there are no dangling leaves that do not encode for a character. The figure below shows a sample ternary Huffman tree; the characters 'a' and 'e' are encoded using one ternary symbol; the less frequently occurring characters 's' and 'p' are encoded using two ternary symbols; and the very rare symbols 'x', 'q' and 'y' are encoded using three ternary symbols each. Of course, if we want to decompress a list of Nary symbols later on, it is important to know which tree was used to compress the data. This can be done in several ways. In this problem we use the following method: the stream of data will be preceded by a header consisting of the encoded versions of the Z characters occurring in the original file, in lexicographical order. Given the number of source symbols Z, a value N denoting the 'arity' of the Huffman tree, and a header, give the mapping from source symbols to encoded symbols. Input The input starts with a single integer T on a separate line, denoting the number of test cases that follow. Next, for each of the T test cases, three lines follow: > The number of different characters in the file (2 <= Z <= 20); > The number N, denoting the 'arity' of the Huffman tree (2 <= N <= 10); > A string representing the header of the received message; each character will be a digit in the range [0, (N1)]. This string will contain less than 200 characters. Note: Although rare, it is possible for a header to have multiple interpretations (e.g., the header '010011101100' with Z = 5 and N = 2). It is guaranteed that all cases in the test input have a unique solution. Output For each of the T testcases, print Z lines giving the encoded version of each of the Z characters in the testcase in ascending order. Use the format original>encoding, where original is a decimal value in the range [0, (Z1)] and encoding is the string of encoding digits for this symbol (each digit is >= 0 and < N). Sample Input 3 3 2 10011 4 2 000111010 19 10 01234678950515253545556575859 Sample Output 0>10 1>0 2>11 0>00 1>011 2>1 3>010 0>0 1>1 2>2 3>3 4>4 5>6 6>7 7>8 8>9 9>50 10>51 11>52 12>53 13>54 14>55 15>56 16>57 17>58 18>59
Matrix Multiplication _course
20170207Description You are given three n × n matrices A, B and C. Does the equation A × B = C hold true? Input The first line of input contains a positive integer n (n ≤ 500) followed by the the three matrices A, B and C respectively. Each matrix's description is a block of n × n integers. It guarantees that the elements of A and B are less than 100 in absolute value and elements of C are less than 10,000,000 in absolute value. Output Output "YES" if the equation holds true, otherwise "NO". Sample Input 2 1 0 2 3 5 1 0 8 5 1 10 26 Sample Output YES
Quantity of White Mice _course
20171015Description There is a species of white mouse to be used in experiments. The mice keep alive only n months after their birth (9 < n < 13, n is natural number, the month to be calculated from the mice's birth, for example, the mice born in Jan have been existed 4 months in Apr.). They begin giving birth to new mice from the 7th month. In the period of the 7th and 8th months every pair of the parent mice give birth to one pair of mice. From the 9th month in a period of m months (0 < m < 3, m is natural number) every pair of the parent mice give birth to two pairs of mice. Thereafter, they stop giving birth and live to the end of their life; they die at the beginning of n+1th month. (The n+1th month doesn't be calculated as exist time of the mice), and the died mice will be took out from this lab. In each month, the number of living mice from previous month is countered first. If the number of the living mice from the previous month is less than or equal to 100 pairs, the new born mice of this month will stay in this lab, if the number of living mice exceeds 100 pairs, the new born mice of this month will be moved to another laboratory. Let there be only one pair of newborn mice at the beginning. How many pairs of mice in the kth month in this lab (0 < k < 37, k is a natural number)? Input On every line, a group of data is given. In each group there are three natural number n,m,k, separated by commas. After all data are given there is 1 as the symbol of termination. Output Find the number of white mice according to the input data in each group. One line is for every output. Its fore part is a repetition of the input data and then it follows a colon and a space. The last part of it is the computed number of the white mice. Sample Input 10,1,6 10,1,7 10,1,9 10,1,10 10,1,11 1 Sample Output 10,1,6: 1 10,1,7: 2 10,1,9: 5 10,1,10: 5 10,1,11: 4
RSI _course
20161227Description You have the goal of becoming the world’s fastest twofingered typist. In this problem, your goal is to optimize the movement of your fingers when typing numeric values in order to ensure that you finish typing a number in the shortest amount of time possible. Your numeric keyboard has the following layout: For convenience, we refer to the cells above according to their row and column; hence, the “5” key is at position (2, 2), and the “0” key takes up both positions (4, 1) and (4, 2). At time 0, your left pointer finger is on the “4” key and your right pointer finger is on the “5” key. During each time interval, each finger may press the key underneath it, move vertically one position, or move horizontally one position. Although both fingers may move simultaneously within a single time interval, at most one key may be pressed during any given time interval, the left pointer finger’s column must always be less than the right pointer finger’s column at the end of each time interval, and both fingers must always be above one of the 10 keys in the diagram at the end of each time interval (e.g., neither finger cannot hover over position (4, 3)). The “0” key may be pressed by a finger at either positions (4, 1) or (4, 2). Examples Typing “56” takes three time units. At time 1, both left and right fingers have moved one position to the right and are on keys “5” and “6” respectively. Then, each key is pressed sequentially. Typing “71” takes five time units. During the first two time units, the left finger moves up to the “7” and presses the key. However, the right finger is not allowed to be in the same column as the left finger, and hence the left finger takes two time units to get to the “1” key and one time unit to press it. Input The input test file will contain multiple test cases. Each test case consists of a single line containing a string of between 1 and 100 digits. The endoffile is marked by a line containing the word “eof” and should not be processed. Output For each input case, output the minimum number of time units required to type the given digits. Sample Input 56 71 902 eof Sample Output 3 5 6
The Snail _course
20171015Description A snail is at the bottom of a 6foot well and wants to climb to the top. The snail can climb 3 feet while the sun is up, but slides down 1 foot at night while sleeping. The snail has a fatigue factor of 10%, which means that on each successive day the snail climbs 10% * 3 = 0.3 feet less than it did the previous day. (The distance lost to fatigue is always 10% of the first day's climbing distance.) On what day does the snail leave the well, i.e., what is the first day during which the snail's height exceeds 6 feet? (A day consists of a period of sunlight followed by a period of darkness.) As you can see from the following table, the snail leaves the well during the third day. Day Initial Height Distance Climbed Height After Climbing Height After Sliding 1 0' 3' 3' 2' 2 2' 2.7' 4.7' 3.7' 3 3.7' 2.4' 6.1'  Your job is to solve this problem in general. Depending on the parameters of the problem, the snail will eventually either leave the well or slide back to the bottom of the well. (In other words, the snail's height will exceed the height of the well or become negative.) You must find out which happens first and on what day. Input The input contains one or more test cases, each on a line by itself. Each line contains four integers H, U, D, and F, separated by a single space. If H = 0 it signals the end of the input; otherwise, all four numbers will be between 1 and 100, inclusive. H is the height of the well in feet, U is the distance in feet that the snail can climb during the day, D is the distance in feet that the snail slides down during the night, and F is the fatigue factor expressed as a percentage. The snail never climbs a negative distance. If the fatigue factor drops the snail's climbing distance below zero, the snail does not climb at all that day. Regardless of how far the snail climbed, it always slides D feet at night. Output For each test case, output a line indicating whether the snail succeeded (left the well) or failed (slid back to the bottom) and on what day. Format the output exactly as shown in the example. Sample Input 6 3 1 10 10 2 1 50 50 5 3 14 50 6 4 1 50 6 3 1 1 1 1 1 0 0 0 0 Sample Output success on day 3 failure on day 4 failure on day 7 failure on day 68 success on day 20 failure on day 2
 3.16MB
AB153XUT络达1562A检测工具最新版
20200928解压密码是FNF//////666,请输入字母和数字部分中间删去. 安卓系统下的络达1562A检测软件AB153XUT. 市场鱼龙混杂,在不拆机的情况下用此软件大致判断出是否是真1562a.
MATLAB基础入门课程
20170913MATLAB基础入门课程，系统介绍MATLAB的基础知识。 主要从数组、运算、结构和绘图等几方面进行讲解 简单易懂，轻松入门MATLAB
HoloLens2开发入门教程
20200501本课程为HoloLens2开发入门教程，讲解部署开发环境，安装VS2019，Unity版本，Windows SDK，创建Unity项目，讲解如何使用MRTK，编辑器模拟手势交互，打包VS工程并编译部署应用到HoloLens上等。
 博客 20201025 二进制写文件
 下载 wecon人机界面直流电源屏的应用
 学院 Cocos Creator 飞机大战微信小游戏开发
 下载 PHP语法自动检查的Vim插件
 下载 PHP JSON出错：Cannot use object of type stdClass as array解决方法
 博客 redux日志记录——reduxlogger
 学院 架构师套餐/JVM/高并发/微服务/Docker等
 学院 基于RK3399和OpenCV实现实时视频增强
 学院 JavaWeb化妆品购物商城毕业设计 大学生毕业设计教学视频
 博客 腾讯数据库专家多年运维经验凝聚成简，总结这份595页工作笔记
 博客 JZ11二进制中1的个数
 下载 jquery中$(#form :input)与$(#form input)的区别
 下载 安居客二手房和新房.py
 学院 JavaWeb手机数码购物商城毕业设计 大学生毕业设计教学视频
 学院 JavaWeb鲜花礼品购物商城毕业设计 大学生毕业设计教学视频
 博客 PHP中的static关键字
 学院 Windows脚本bat文件批处理基础教程
 博客 simulink命令集及常用模块说明
 学院 Spring Boot+Bootstrap开发小而完整web项目
 学院 Java微信小程序珠宝首饰购物商城 大学生毕业设计教学视频
 学院 全新Vue3.0全家桶 零基础入门到项目实战
 学院 专为AI小白设计的人工智能实战课
 博客 HTML5+CSS3 吃豆豆代码
 下载 虚拟仪器在磁轴承数字控制中的应用
 学院 Spring核心原理面试训练营（停止报名）
 下载 linux i2ctools源码i2ctools3.0.1.tar.gz
 博客 T系统和应用集成从SOA架构思想到服务架构规划设计
 下载 EH600W(A)系列变频器在双变频拉丝机上的应用
 下载 相机专家LACM系列相机使用说明
 学院 【数据分析】 量化交易策略模型