- Lagrange's Four-Square Theorem
The fact that any positive integer has a representation as the sum of at most four positive squares (i.e. squares of positive integers) is known as Lagrange's Four-Square Theorem. The first published proof of the theorem was given by Joseph-Louis Lagrange in 1770. Your mission however is not to explain the original proof nor to discover a new proof but to show that the theorem holds for some specific numbers by counting how many such possible representations there are.
For a given positive integer n, you should report the number of all representations of n as the sum of at most four positive squares. The order of addition does not matter, e.g. you should consider 4^2 + 3^2 and 3^2 + 4^2 are the same representation.
For example, let's check the case of 25. This integer has just three representations 1^2+2^2+2^2+4^2, 3^2 + 4^2, and 5^2. Thus you should report 3 in this case. Be careful not to count 4^2 + 3^2 and 3^2 + 4^2 separately.
The input is composed of at most 255 lines, each containing a single positive integer less than 2^15, followed by a line containing a single zero. The last line is not a part of the input data.
The output should be composed of lines, each containing a single integer. No other characters should appear in the output.
The output integer corresponding to the input integer n is the number of all representations of n as the sum of at most four positive squares.
Map of Ninja House _course2017-10-17
Description 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 i-th 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
Description A pretty straight forward task, calculate the number of primes between 2 integers. Given 2 integers A ≤ B < 105 what’s the number of primes in range from A to B inclusive. Note: A prime number is a positive integer greater than 1 and is divisible by 1 and itself only. For N to be prime it is enough to test the divisibility of numbers less than or equal to square root of N. Input As many as 1000 lines, each line contains 2 integers A and B separated by a space. Input is terminated when A = B = -1 (Do not process this line). Output For every line in input – except for the last line where A = B = -1 - print the number of prime numbers between A and B inclusive. Sample Input 0 9999 1 5 -1 -1 Sample Output 1229 3
Description A triangle is a basic shape of planar geometry. It consists of three straight lines and three angles in between. Figure 1 shows how the sides and angles are usually labeled. !(http://poj.org/images/1347_1.jpg) A look into a book about geometry shows that many formulas for triangles exist: alpha + beta + gamma = PI a / sin (alpha) = b / sin (beta) = c / sin ( gamma ) a = b cos (gamma) + c cos (beta) a^2 = b^2 + c^2 - 2bc*cos (alpha) (a - b) / (a + b) = tan((alpha - beta) / 2) / tan((alpha + beta) / 2) The values of a, b, c, alpha, beta, and gamma form a set of six parameters that fully define a triangle. If a large enough subset of these parameters is given, the missing ones can be calculated by using the formulas above. You are to write a program that calculates the missing parameters for a given subset of the six parameters of a triangle. For some sets of parameters, it is not possible to calculate the triangle because either too few is known about the triangle or the parameters would lead to an invalid triangle. The sides of a valid triangle are greater than 0 and the angles are greater than 0 and less than PI. Your program should detect this case and output: "Invalid input." The same phrase should be output if more than the minimal set needed to compute the triangle is given but the parameters conflict with each other, e.g. all three angles are given but their sum is greater than PI. Other sets of parameters can lead to more than one but still a finite number of valid solutions for the triangle. In such a case, your program should output: "More than one solution." In all other cases, your program should compute the missing parameters and output all six parameters. Input The first line of the input file contains a number indicating the number of parameter sets to follow. Each following line consists of six numbers, separated by a single blank character. The numbers are the values for the parameters a, alpha , b, beta, c, and gamma respectively. The parameters are labeled as shown in figure 1. A value of -1 indicates that the corresponding parameter is undefined and has to be calculated. All floating-point numbers include at least eight significant digits. Output Your program should output a line for each set of parameters found in the input file. If a unique solution for a valid triangle can be found for the given parameters, your program should output the six parameters a, alpha, b, beta, c, gamma, separated by a blank character. Otherwise the line should contain the phrase "More than one solution." or "Invalid input." as explained above. The numbers in the output file should include at least six significant digits. Your calculations should be precise enough to get the six most significant digits correct (i.e. a relative error of 0.000001 is allowed). Sample Input 4 47.9337906847 0.6543010109 78.4455517579 1.4813893731 66.5243757656 1.0059022695 62.72048064 2.26853639 -1.00000000 0.56794657 -1.00000000 -1.00000000 15.69326944 0.24714213 -1.00000000 1.80433105 66.04067877 -1.00000000 72.83685175 1.04409241 -1.00000000 -1.00000000 -1.00000000 -1.00000000 Sample Output 47.933791 0.654301 78.445552 1.481389 66.524376 1.005902 62.720481 2.268536 44.026687 0.567947 24.587225 0.305110 Invalid input. Invalid input.
Magic Number _course2017-02-15
Problem Description There are many magic numbers whose lengths are less than 10. Given some queries, each contains a single number, if the Levenshtein distance (see below) between the number in the query and a magic number is no more than a threshold, we call the magic number is the lucky number for that query. Could you find out how many luck numbers are there for each query? Levenshtein distance (from Wikipedia http://en.wikipedia.org/wiki/Levenshtein_distance): In information theory and computer science, the Levenshtein distance is a string metric for measuring the amount of difference between two sequences. The term edit distance is often used to refer specifically to Levenshtein distance. The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character. It is named after Vladimir Levenshtein, who considered this distance in 1965. For example, the Levenshtein distance between "kitten" and "sitting" is 3, since the following three edits change one into the other, and there is no way to do it with fewer than three edits: 1.kitten → sitten (substitution of 's' for 'k') 2.sitten → sittin (substitution of 'i' for 'e') 3.sittin → sitting (insertion of 'g' at the end). Input There are several test cases. The first line contains a single number T shows that there are T cases. For each test case, there are 2 numbers in the first line: n (n <= 1500) m (m <= 1000) where n is the number of magic numbers and m is the number of queries. In the next n lines, each line has a magic number. You can assume that each magic number is distinctive. In the next m lines, each line has a query and a threshold. The length of each query is no more than 10 and the threshold is no more than 3. Output For each test case, the first line is "Case #id:", where id is the case number. Then output m lines. For each line, there is a number shows the answer of the corresponding query. Sample Input 1 5 2 656 67 9313 1178 38 87 1 9509 1 Sample Output Case #1: 1 0
Solving the Problems _course2017-08-22
Programming is fun, Aaron is addicted to it. In order to improve his programming skill, he decides to solve one programming problem per day. As you know, different problems have different properties, some problems are so difficult that there are few people can solve it, while some problems are so easy that almost everyone is able to tackle it. Programming skill can be measured by an integer p. And all problems are described by two integers ai and bi. ai indicates that if and only if P >= ai, you can solve this problem. bi indicates that after you solve this problem, your programming skill can be increased by bi. Given the initial programming skill p of Aaron, and the information of each problem, Aaron want to know the maximal programming skill he can reach after m days, can you help him? Input Input consists of multiple test cases (less than 40 cases)! For each test case, the first line contains three numbers: n, m, p (1 <= n <= 100000, 1 <= m <= n, 1 <= p <= 10000), n is the number of problems available for Aaron, m, p as mentioned above. The following n lines each contain two numbers: ai and bi (1 <= ai <= 10000, 1 <= bi <= 10000) describe the information of the i-th problem as memtioned above. There's a blank line between consecutive cases. Output For each case, output the maximal programming skill Aaron can reach after m days in a line. Sample Input 2 2 1 1 2 7 3 3 1 2 1 2 2 3 3 4 Sample Output 3 5
Lagrange's Four-Square Theorem _course2017-05-09
The fact that any positive integer has a representation as the sum of at most four positive squares (i.e. squares of positive integers) is known as Lagrange's Four-Square Theorem. The first published proof of the theorem was given by Joseph-Louis Lagrange in 1770. Your mission however is not to explain the original proof nor to discover a new proof but to show that the theorem holds for some specific numbers by counting how many such possible representations there are. For a given positive integer n, you should report the number of all representations of n as the sum of at most four positive squares. The order of addition does not matter, e.g. you should consider 4^2 + 3^2 and 3^2 + 4^2 are the same representation. For example, let's check the case of 25. This integer has just three representations 1^2+2^2+2^2+4^2, 3^2 + 4^2, and 5^2. Thus you should report 3 in this case. Be careful not to count 4^2 + 3^2 and 3^2 + 4^2 separately. Input The input is composed of at most 255 lines, each containing a single positive integer less than 2^15, followed by a line containing a single zero. The last line is not a part of the input data. Output The output should be composed of lines, each containing a single integer. No other characters should appear in the output. The output integer corresponding to the input integer n is the number of all representations of n as the sum of at most four positive squares. Sample Input 1 25 2003 211 20007 0 Sample Output 1 3 48 7 738
Gas Station Numbers _course2017-10-05
Description Many gas stations use plastic digits on an illuminated sign to indicate prices. When there is an insufficient quantity of a particular digit, the attendant may substitute another one upside down. The digit "6" looks much like "9" upside down. The digits "0", "1" and "8" look like themselves. The digit "2" looks a bit like a "5" upside down (well, at least enough so that gas stations use it). Due to rapidly increasing prices, a certain gas station has used all of its available digits to display the current price. Fortunately, this shortage of digits need not prevent the attendant from raising prices. She can simply rearrange the digits, possibly reversing some of them as described above. Your job is to compute, given the current price of gas, the next highest price that can be displayed using exactly the same digits. Input The input consists of several lines, each containing between 2 and 30 digits (to account for future prices) and a decimal point immediately before the last digit. There are no useless leading zeroes; that is, there is a leading zero only if the price is less than 1. Output You are to compute the next highest price that can be displayed using the same digits and the same format rules. An input line containing a decimal point alone terminates the input. If the price cannot be raised, print "The price cannot be raised." Sample Input 65.2 76.7 77.7 . Sample Output 65.5 77.6 The price cannot be raised.
Knights of the Round Table _course2017-10-12
Description Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in distress, and drinking with the other knights are fun things to do. Therefore, it is not very surprising that in recent years the kingdom of King Arthur has experienced an unprecedented increase in the number of knights. There are so many knights now, that it is very rare that every Knight of the Round Table can come at the same time to Camelot and sit around the round table; usually only a small group of the knights isthere, while the rest are busy doing heroic deeds around the country. Knights can easily get over-excited during discussions-especially after a couple of drinks. After some unfortunate accidents, King Arthur asked the famous wizard Merlin to make sure that in the future no fights break out between the knights. After studying the problem carefully, Merlin realized that the fights can only be prevented if the knights are seated according to the following two rules: The knights should be seated such that two knights who hate each other should not be neighbors at the table. (Merlin has a list that says who hates whom.) The knights are sitting around a roundtable, thus every knight has exactly two neighbors. An odd number of knights should sit around the table. This ensures that if the knights cannot agree on something, then they can settle the issue by voting. (If the number of knights is even, then itcan happen that ``yes" and ``no" have the same number of votes, and the argument goes on.) Merlin will let the knights sit down only if these two rules are satisfied, otherwise he cancels the meeting. (If only one knight shows up, then the meeting is canceled as well, as one person cannot sit around a table.) Merlin realized that this means that there can be knights who cannot be part of any seating arrangements that respect these rules, and these knights will never be able to sit at the Round Table (one such case is if a knight hates every other knight, but there are many other possible reasons). If a knight cannot sit at the Round Table, then he cannot be a member of the Knights of the Round Table and must be expelled from the order. These knights have to be transferred to a less-prestigious order, such as the Knights of the Square Table, the Knights of the Octagonal Table, or the Knights of the Banana-Shaped Table. To help Merlin, you have to write a program that will determine the number of knights that must be expelled. Input The input contains several blocks of test cases. Each case begins with a line containing two integers 1 ≤ n ≤ 1000 and 1 ≤ m ≤ 1000000 . The number n is the number of knights. The next m lines describe which knight hates which knight. Each of these m lines contains two integers k1 and k2 , which means that knight number k1 and knight number k2 hate each other (the numbers k1 and k2 are between 1 and n ). The input is terminated by a block with n = m = 0 . Output For each test case you have to output a single integer on a separate line: the number of knights that have to be expelled. Sample Input 5 5 1 4 1 5 2 5 3 4 4 5 0 0 Sample Output 2
Washing Clothes _course2017-10-17
Description Dearboy was so busy recently that now he has piles of clothes to wash. Luckily, he has a beautiful and hard-working girlfriend to help him. The clothes are in varieties of colors but each piece of them can be seen as of only one color. In order to prevent the clothes from getting dyed in mixed colors, Dearboy and his girlfriend have to finish washing all clothes of one color before going on to those of another color. From experience Dearboy knows how long each piece of clothes takes one person to wash. Each piece will be washed by either Dearboy or his girlfriend but not both of them. The couple can wash two pieces simultaneously. What is the shortest possible time they need to finish the job? Input The input contains several test cases. Each test case begins with a line of two positive integers M and N (M < 10, N < 100), which are the numbers of colors and of clothes. The next line contains M strings which are not longer than 10 characters and do not contain spaces, which the names of the colors. Then follow N lines describing the clothes. Each of these lines contains the time to wash some piece of the clothes (less than 1,000) and its color. Two zeroes follow the last test case. Output For each test case output on a separate line the time the couple needs for washing. Sample Input 3 4 red blue yellow 2 red 3 blue 4 blue 6 red 0 0 Sample Output 10
Problem Description Betty owns a lot of ponds, some of them are connected with other ponds by pipes, and there will not be more than one pipe between two ponds. Each pond has a value v. Now Betty wants to remove some ponds because she does not have enough money. But each time when she removes a pond, she can only remove the ponds which are connected with less than two ponds, or the pond will explode. Note that Betty should keep removing ponds until no more ponds can be removed. After that, please help her calculate the sum of the value for each connected component consisting of a odd number of ponds Input The first line of input will contain a number T(1≤T≤30) which is the number of test cases. For each test case, the first line contains two number separated by a blank. One is the number p(1≤p≤104) which represents the number of ponds she owns, and the other is the number m(1≤m≤105) which represents the number of pipes. The next line contains p numbers v1,...,vp, where vi(1≤vi≤108) indicating the value of pond i. Each of the last m lines contain two numbers a and b, which indicates that pond a and pond b are connected by a pipe. Output For each test case, output the sum of the value of all connected components consisting of odd number of ponds after removing all the ponds connected with less than two pipes. Sample Input 1 7 7 1 2 3 4 5 6 7 1 4 1 5 4 5 2 3 2 6 3 6 2 7 Sample Output 21
Description Bob and Alice started to use a brand-new encoding scheme. Surprisingly it is not a Public Key Cryptosystem, but their encoding and decoding is based on secret keys. They chose the secret key at their last meeting in Philadelphia on February 16th, 1996. They chose as a secret key a sequence of n distinct integers, a1 ; . . .; an, greater than zero and less or equal to n. The encoding is based on the following principle. The message is written down below the key, so that characters in the message and numbers in the key are correspondingly aligned. Character in the message at the position i is written in the encoded message at the position ai, where ai is the corresponding number in the key. And then the encoded message is encoded in the same way. This process is repeated k times. After kth encoding they exchange their message. The length of the message is always less or equal than n. If the message is shorter than n, then spaces are added to the end of the message to get the message with the length n. Help Alice and Bob and write program which reads the key and then a sequence of pairs consisting of k and message to be encoded k times and produces a list of encoded messages. Input The input file consists of several blocks. Each block has a number 0 < n <= 200 in the first line. The next line contains a sequence of n numbers pairwise distinct and each greater than zero and less or equal than n. Next lines contain integer number k and one message of ascii characters separated by one space. The lines are ended with eol, this eol does not belong to the message. The block ends with the separate line with the number 0. After the last block there is in separate line the number 0. Output Output is divided into blocks corresponding to the input blocks. Each block contains the encoded input messages in the same order as in input file. Each encoded message in the output file has the lenght n. After each block there is one empty line. Sample Input 10 4 5 3 7 2 8 1 6 10 9 1 Hello Bob 1995 CERC 0 0 Sample Output BolHeol b C RCE
Frame Polygonal Line _course2017-08-07
You are going to read a sequence of pairs of integer numbers. Each pair represents the Cartesian coordinates of a point in a 2-dimentional plane. The first number is the x coordinate, while the second is that of y. The sequence represents a polygonal line. Your task is to draw a rectangle with minimal length of sides that exactly surrounds the polygonal line. The sides of the rectangle are parallel to x- and y-axis, respectively. Input Input consists of several test cases. For each case, a sequence of coordinates is given. Each pair of x and y occupies a line, with |x| and |y| less than 2^31. The sequence is terminated with a pair of 0's. Note that (0, 0) will never be considered as a point on any of the polygonal lines. An empty polygonal line signals the end of input. Output For each test case, print in one line two pairs of numbers, which are the south-west and north-east corners of the surrounding rectangle. The numbers must be separated by one space as is indicated in the samples. Sample Input 12 56 23 56 13 10 0 0 12 34 0 0 0 0 Sample Output 12 10 23 56 12 34 12 34
Prime Gap _course2017-10-06
Description The sequence of n − 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers p and p + n is called a prime gap of length n. For example, ‹24, 25, 26, 27, 28› between 23 and 29 is a prime gap of length 6. Your mission is to write a program to calculate, for a given positive integer k, the length of the prime gap that contains k. For convenience, the length is considered 0 in case no prime gap contains k. Input The input is a sequence of lines each of which contains a single positive integer. Each positive integer is greater than 1 and less than or equal to the 100000th prime number, which is 1299709. The end of the input is indicated by a line containing a single zero. Output The output should be composed of lines each of which contains a single non-negative integer. It is the length of the prime gap that contains the corresponding positive integer in the input if it is a composite number, or 0 otherwise. No other characters should occur in the output. Sample Input 10 11 27 2 492170 0 Sample Output 4 0 6 0 114
Currency Exchange _course2016-11-16
Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be several points specializing in the same pair of currencies. Each point has its own exchange rates, exchange rate of A to B is the quantity of B you get for 1A. Also each exchange point has some commission, the sum you have to pay for your exchange operation. Commission is always collected in source currency. For example, if you want to exchange 100 US Dollars into Russian Rubles at the exchange point, where the exchange rate is 29.75, and the commission is 0.39 you will get (100 - 0.39) * 29.75 = 2963.3975RUR. You surely know that there are N different currencies you can deal with in our city. Let us assign unique integer number from 1 to N to each currency. Then each exchange point can be described with 6 numbers: integer A and B - numbers of currencies it exchanges, and real RAB, CAB, RBA and CBA - exchange rates and commissions when exchanging A to B and B to A respectively. Nick has some money in currency S and wonders if he can somehow, after some exchange operations, increase his capital. Of course, he wants to have his money in currency S in the end. Help him to answer this difficult question. Nick must always have non-negative sum of money while making his operations. Input The first line of the input contains four numbers: N - the number of currencies, M - the number of exchange points, S - the number of currency Nick has and V - the quantity of currency units he has. The following M lines contain 6 numbers each - the description of the corresponding exchange point - in specified above order. Numbers are separated by one or more spaces. 1<=S<=N<=100, 1<=M<=100, V is real number, 0<=V<=103. For each point exchange rates and commissions are real, given with at most two digits after the decimal point, 10-2<=rate<=102, 0<=commission<=102. Let us call some sequence of the exchange operations simple if no exchange point is used more than once in this sequence. You may assume that ratio of the numeric values of the sums at the end and at the beginning of any simple sequence of the exchange operations will be less than 104. Output If Nick can increase his wealth, output YES, in other case output NO to the output file. Sample Input 3 2 1 20.0 1 2 1.00 1.00 1.00 1.00 2 3 1.10 1.00 1.10 1.00 Sample Output YES
Description To enable homebuyers to estimate the cost of flood insurance, a real-estate firm provides clients with the elevation of each 10-meter by 10-meter square of land in regions where homes may be purchased. Water from rain, melting snow, and burst water mains will collect first in those squares with the lowest elevations, since water from squares of higher elevation will run downhill. For simplicity, we also assume that storm sewers enable water from high-elevation squares in valleys (completely enclosed by still higher elevation squares) to drain to lower elevation squares, and that water will not be absorbed by the land. From weather data archives, we know the typical volume of water that collects in a region. As prospective homebuyers, we wish to know the elevation of the water after it has collected in low-lying squares, and also the percentage of the region's area that is completely submerged (that is, the percentage of 10-meter squares whose elevation is strictly less than the water level). You are to write the program that provides these results. Input The input consists of a sequence of region descriptions. Each begins with a pair of integers, m and n, each less than 30, giving the dimensions of the rectangular region in 10-meter units. Immediately following are m lines of n integers giving the elevations of the squares in row-major order. Elevations are given in meters, with positive and negative numbers representing elevations above and below sea level, respectively. The final value in each region description is an integer that indicates the number of cubic meters of water that will collect in the region. A pair of zeroes follows the description of the last region. Output For each region, display the region number (1, 2, ...), the water level (in meters above or below sea level) and the percentage of the region's area under water, each on a separate line. The water level and percentage of the region's area under water are to be displayed accurate to two fractional digits. Follow the output for each region with a blank line. Sample Input 3 3 25 37 45 51 12 34 94 83 27 10000 0 0 Sample Output Region 1 Water level is 46.67 meters. 66.67 percent of the region is under water.
Pit Stop Strategy _course2017-09-06
The speed of a racing car, all other factors being equal, depends on the amount of fuel it carries. In general, the weight of the fuel slows the car. In addition, the weight of the fuel increases fuel consumption. It is therefore an advantage to carry as little fuel as possible. Any amount of fuel may be loaded at the beginning of the race, and refueling pit shops may be made during the race. The time consumed for the pit stop increases with the amount of fuel loaded. Your task is to determine the optimal fueling and pit stop strategy for each of a number of cars, based on measurements taken immediately before the race. Input Standard input consists of several lines of input, each containing: the number of laps in the race (integer less than or equal to 100) the theoretical lap time [second] of the car on an empty tank (float) the increase in lap time (float) per liter of fuel carried at the beginning of the lap (float) the theoretical fuel consumption [liters per lap] on an empty tank (float) the increase in fuel consumption per liter of fuel carried at the beginning of the lap (float; strictly less than 1) the time [seconds] for a pit stop taking on no fuel (float) the extra pit stop time per liter of fuel loaded (float) Output For each input line, print the following information one line containing the seven input numbers in order one line containing three integers: total race time the amount of fuel to be loaded initially the number of pit stops for each pit stop, a line containing: the number of laps completed since the start of the race at the time of the pit stop the amount of fuel to be taken on All floating point results should be printed to 6 significant figures. All numbers on a single line be separated by a single space. If there are several optimal strategies, break the tie with an earlier pit stop. Sample Input 3 100 0 10 0 20 0 3 100 0 10 .1 20 0 3 100 2 10 0 20 1 3 100 4 10 0 20 1 3 100 2 10 .1 20 1 Sample Output 3 100 0 10 0 20 0 300 30 0 3 100 0 10 0.1 20 0 300 37.1742 0 3 100 2 10 0 20 1 410 20 1 2 10 3 100 4 10 0 20 1 480 10 2 1 10 2 10 3 100 2 10 0.1 20 1 422.469 23.4568 1 2 11.1111
Professor Robert A. J. Matthews of the Applied Mathematics and Computer Science Department at the University of Aston in Birmingham, England has recently described how the positions of stars across the night sky may be used to deduce a surprisingly accurate value of Pi. This result followed from the application of certain theorems in number theory. Here, we don't have the night sky, but can use the same theoretical basis to form an estimate for Pi: Given any pair of whole numbers chosen from a large, random collection of numbers, the probability that the two numbers have no common factor other than one (1) is 6/Pi^2 For example, using the small collection of numbers: 2, 3, 4, 5, 6; there are 10 pairs that can be formed: (2,3), (2,4), etc. Six of the 10 pairs: (2,3), (2,5), (3,4), (3,5), (4,5) and (5,6) have no common factor other than one. Using the ratio of the counts as the probability we have: 6/Pi^2 = 6/10 Pi = 3.162 In this problem, you'll receive a series of data sets. Each data set contains a set of pseudo-random positive integers. For each data set, find the portion of the pairs which may be formed that have no common factor other than one (1), and use the method illustrated above to obtain an estimate for Pi. Report this estimate for each data set. Input The input consists of a series of data sets. The first line of each data set contains a positive integer value, N, greater than one (1) and less than 50. There is one positive integer per line for the next N lines that constitute the set for which the pairs are to be examined. These integers are each greater than 0 and less than 32768. Each integer of the input stream has its first digit as the first character on the input line. The set size designator, N, will be zero to indicate the end of data. Output A line with a single real value is to be emitted for each input data set encountered. This value is the estimate for Pi for the data set. An output format like the sample below should be used. Answers must be rounded to six digits after the decimal point. For some data sets, it may be impossible to estimate a value for Pi. This occurs when there are no pairs without common factors. In these cases, emit the single-line message: No estimate for this data set. exactly, starting with the first character, "N", as the first character on the line. Sample Input 5 2 3 4 5 6 2 13 39 0 Sample Output 3.162278 No estimate for this data set.
2020数学建模国赛A题及其数据 2020数学建模国赛A题及其数据2020数学建模国赛A题及其数据 2020数学建模国赛A题及其数据 2020数学建模国赛A题及其数据 2020数学建模国赛A题及其数据
限时福利1：购课进答疑群专享柳峰（刘运强）老师答疑服务。 为什么说每一个程序员都应该学习MySQL？ 根据《2019-2020年中国开发者调查报告》显示，超83%的开发者都在使用MySQL数据库。 使用量大同时，掌握MySQL早已是运维、DBA的必备技能，甚至部分IT开发岗位也要求对数据库使用和原理有深入的了解和掌握。 学习编程，你可能会犹豫选择 C++ 还是 Java；入门数据科学，你可能会纠结于选择 Python 还是 R；但无论如何， MySQL 都是 IT 从业人员不可或缺的技能！ 【课程设计】 在本课程中，刘运强老师会结合自己十多年来对MySQL的心得体会，通过课程给你分享一条高效的MySQL入门捷径，让学员少走弯路，彻底搞懂MySQL。 本课程包含3大模块： 一、基础篇： 主要以最新的MySQL8.0安装为例帮助学员解决安装与配置MySQL的问题，并对MySQL8.0的新特性做一定介绍，为后续的课程展开做好环境部署。 二、SQL语言篇： 本篇主要讲解SQL语言的四大部分数据查询语言DQL，数据操纵语言DML，数据定义语言DDL，数据控制语言DCL，学会熟练对库表进行增删改查等必备技能。 三、MySQL进阶篇： 本篇可以帮助学员更加高效的管理线上的MySQL数据库；具备MySQL的日常运维能力，语句调优、备份恢复等思路。
微信小程序 实例汇总 完整项目源代码2016-11-01
微信小程序 实例汇总 完整项目源代码
- 博客 ETX聚盛国际外汇-首家全方位交易与托管模式平台
- 下载 简析LED照明在实际应用中的热特性(组图）
- 学院 MT5智能交易之路：MQL5语法指南
- 学院 程序员的数学通关课
- 博客 魔力耳朵被豌豆思维全资收购，创始人金磊退出股东
- 博客 CTF解题技能之MISC基础
- 博客 replace()用法
- 下载 基础电子中的液晶电视连接电脑相关事宜
- 下载 电源技术中的智能型太阳能充电电路设计
- 学院 2020年软考网络规划设计师-论文写作套路精讲视频课程
- 下载 德特威勒开启式地面插座盒的结构与应用
- 下载 基础电子中的Magelis的以太网应用
- 学院 Spring AOP从认识到源码
- 博客 LeetCode C++ 33. Search in Rotated Sorted Array【二分】中等
- 学院 Java微信小程序珠宝首饰购物商城 大学生毕业设计教学视频
- 下载 电源技术中的开关电源谐波的研究
- 下载 新型混合动力汽车检测技术
- 下载 解决 .NET Core 中 GetHostAddressesAsync 引起的 EnyimMemcached 死锁问题
- 博客 Apache低版本目录遍历漏洞
- 下载 原生js仿jquery一些常用方法(必看篇)
- 下载 js style.display=block显示布局错乱问题的解决方法
- 下载 D3.js实现折线图的方法详解
- 博客 形式语言中形式语法四种类型的通俗理解
- 学院 Unity热更新框架-基于ILRuntime
- 下载 详解AngularJs中$sce与$sceDelegate上下文转义服务
- 博客 Ubuntu18.04虚拟机解决窗口自适应
- 学院 跟着蜗牛慢慢学 - Redis
- 博客 云计算运维学习---ssh远程管理服务
- 下载 jquery radio的取值_radio的选中_radio的重置方法
- 学院 3小时快速学习计算机基础