 A + B Again

Problem Description
There must be many A + B problems in our HDOJ , now a new one is coming.
Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too.
Easy ? AC it !Input
The input contains several test cases, please process to the end of the file.
Each case consists of two hexadecimal integers A and B in a line seperated by a blank.
The length of A and B is less than 15.Output
For each test case,print the sum of A and B in hexadecimal in one line.Sample Input
+A A
+1A 12
1A 9
1A 12
1A AASample Output
0
2C
11
2C
90
 其他相关推荐
 A + B Again
 Problem Description There must be many A + B problems in our HDOJ , now a new one is coming. Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too. Easy ? AC it ! Input The input contains several test cases, please process to the end of the file. Each case consists of two hexadecimal integers A and B in a line seperated by a blank. The length of A and B is less than 15. Output For each test case,print the sum of A and B in hexadecimal in one line. Sample Input +A A +1A 12 1A 9 1A 12 1A AA Sample Output 0 2C 11 2C 90
 Farey Sequence Again
 Problem Description The Farey sequence Fn for any positive integer n is the set of irreducible rational numbers a/b with 0<a<b<=n and (a, b) = 1 arranged in increasing order. Here (a, b) mean the greatest common divisor of a and b. For example: F2 = {1/2} F3 = {1/3, 1/2, 2/3} Given two positive integers N and K, with K less than N, you need to find out the Kth smallest element of the Farey sequence FN. Input The first line of input is the number of test case T, 1<=T<=1000. Then each test case contains two positive integers N and K. 1<=K<N<=10^9. Output For each test case output the Kth smallest element of the Farey sequence FN in a single line. Sample Input 3 2 1 100 68 101 69 Sample Output 1/2 2/83 1/42
 Vive la Difference! 怎么实现的
 roblem Description Take any four positive integers: a, b, c, d. Form four more, like this: ab bc cd da That is, take the absolute value of the differences of a with b, b with c, c with d, and d with a. (Note that a zero could crop up, but they’ll all still be nonnegative.) Then, do it again with these four new numbers. And then again. And again. Eventually, all four integers will be the same. For example, start with 1,3,5,9: 1 3 5 9 2 2 4 8 (1) 0 2 4 6 (2) 2 2 2 6 (3) 0 0 4 4 (4) 0 4 0 4 (5) 4 4 4 4 (6) In this case, the sequence converged in 6 steps. It turns out that in all cases, the sequence converges very quickly. In fact, it can be shown that if all four integers are less than 2^n, then it will take no more than 3*n steps to converge! Given a, b, c and d, figure out just how quickly the sequence converges. Input There will be several test cases in the input. Each test case consists of four positive integers on a single line (1 ≤ a,b,c,d ≤ 2,000,000,000), with single spaces for separation. The input will end with a line with four 0s. Output For each test case, output a single integer on its own line, indicating the number of steps until convergence. Output no extra spaces, and do not separate answers with blank lines. Sample Input 1 3 5 9 4 3 2 1 1 1 1 1 0 0 0 0 Sample Output 6 4 0
 A + B for you again
 Problem Description Generally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two strings, such as “asdf” and “sdfg”, the result of the addition between them is “asdfg”, for “sdf” is the tail substring of “asdf” and the head substring of the “sdfg” . However, the result comes as “asdfghjk”, when you have to add “asdf” and “ghjk” and guarantee the shortest string first, then the minimum lexicographic second, the same rules for other additions. Input For each case, there are two strings (the chars selected just form ‘a’ to ‘z’) for you, and each length of theirs won’t exceed 10^5 and won’t be empty. Output Print the ultimate string by the book. Sample Input asdf sdfg asdf ghjk Sample Output asdfg asdfghjk
 Farey Sequence Again 怎么写的
 Problem Description The Farey sequence Fn for any positive integer n is the set of irreducible rational numbers a/b with 0<a<b<=n and (a, b) = 1 arranged in increasing order. Here (a, b) mean the greatest common divisor of a and b. For example: F2 = {1/2} F3 = {1/3, 1/2, 2/3} Given two positive integers N and K, with K less than N, you need to find out the Kth smallest element of the Farey sequence FN. Input The first line of input is the number of test case T, 1<=T<=1000. Then each test case contains two positive integers N and K. 1<=K<N<=10^9. Output For each test case output the Kth smallest element of the Farey sequence FN in a single line. Sample Input 3 2 1 100 68 101 69 Sample Output 1/2 2/83 1/42
 It's not a Bug, It's a Feature! 具体实现
 Problem Description It is a curious fact that consumers buying a new software product generally do not expect the software to be bugfree. Can you imagine buying a car whose steering wheel only turns to the right? Or a CDplayer that plays only CDs with country music on them? Probably not. But for software systems it seems to be acceptable if they do not perform as they should do. In fact, many software companies have adopted the habit of sending out patches to fix bugs every few weeks after a new product is released (and even charging money for the patches). Tinyware Inc. is one of those companies. After releasing a new word processing software this summer, they have been producing patches ever since. Only this weekend they have realized a big problem with the patches they released. While all patches fix some bugs, they often rely on other bugs to be present to be installed. This happens because to fix one bug, the patches exploit the special behavior of the program due to another bug. More formally, the situation looks like this. Tinyware has found a total of n bugs B = {b1, b2, ..., bn} in their software. And they have released m patches p1, p2, ..., pm. To apply patch pi to the software, the bugs Bi+ in B have to be present in the software, and the bugs Bi in B must be absent (of course Bi+ ∩ Bi = Φ). The patch then fixes the bugs Fi in B (if they have been present) and introduces the new bugs Fi+ in B (where, again, Fi+ ∩ Fi = Φ). Tinyware's problem is a simple one. Given the original version of their software, which contains all the bugs in B, it is possible to apply a sequence of patches to the software which results in a bug free version of the software? And if so, assuming that every patch takes a certain time to apply, how long does the fastest sequence take? Input The input contains several product descriptions. Each description starts with a line containing two integers n and m, the number of bugs and patches, respectively. These values satisfy 1 <= n <= 20 and 1 <= m <= 100. This is followed by m lines describing the m patches in order. Each line contains an integer, the time in seconds it takes to apply the patch, and two strings of n characters each. The first of these strings describes the bugs that have to be present or absent before the patch can be applied. The ith position of that string is a ``+'' if bug bi has to be present, a ``'' if bug bi has to be absent, and a `` 0'' if it doesn't matter whether the bug is present or not. The second string describes which bugs are fixed and introduced by the patch. The ith position of that string is a ``+'' if bug bi is introduced by the patch, a ``'' if bug bi is removed by the patch (if it was present), and a ``0'' if bug bi is not affected by the patch (if it was present before, it still is, if it wasn't, is still isn't). The input is terminated by a description starting with n = m = 0. This test case should not be processed. Output For each product description first output the number of the product. Then output whether there is a sequence of patches that removes all bugs from a product that has all n bugs. Note that in such a sequence a patch may be used multiple times. If there is such a sequence, output the time taken by the fastest sequence in the format shown in the sample output. If there is no such sequence, output ``Bugs cannot be fixed.''. Print a blank line after each test case. Sample Input 3 3 1 000 00 1 00 0+ 2 0 ++ 4 1 7 00+  0 0 Sample Output Product 1 Fastest sequence takes 8 seconds. Product 2 Bugs cannot be fixed.
 Farey Sequence Again 程序编写的法则
 Problem Description The Farey sequence Fn for any positive integer n is the set of irreducible rational numbers a/b with 0<a<b<=n and (a, b) = 1 arranged in increasing order. Here (a, b) mean the greatest common divisor of a and b. For example: F2 = {1/2} F3 = {1/3, 1/2, 2/3} Given two positive integers N and K, with K less than N, you need to find out the Kth smallest element of the Farey sequence FN. Input The first line of input is the number of test case T, 1<=T<=1000. Then each test case contains two positive integers N and K. 1<=K<N<=10^9. Output For each test case output the Kth smallest element of the Farey sequence FN in a single line. Sample Input 3 2 1 100 68 101 69 Sample Output 1/2 2/83 1/42
 Cutting trees 程序怎么来做
 Problem Description A rooted graph is an indirected graph with every edge attached by some path to a special vertex called the root or the ground. The ground is denoted in the below figures that follow by a dotted line. A bamboo stalk with n segments is a linear graph of n edges with the bottom of the n edges rooted to the ground. A move consists of hacking away one of the segments, and removing that segment and all segments above it no longer connectd to the ground. Two players alternate moves and the last player to move wins. A single bamboo stalk of n segments can be moved into a bamboo stalk of any smaller number of segments from n1 to 0. So a single bamboo stalk of n segments is equivalent to a nim pile of n chips. As you known, the player who moves first can win the the game with only one bamboo stalk. So many people always play the game with several bamboo stalks. One example is as below: Playing a sum of games of bamboo stalks is thus equivalent to playing a nim game that with several piles. A move consisits of selecting a bamboo stalk containg n segments and hacking away one of the segments in the selected bamboo stalk. I think the nim game is easy for you, the smart ACMers. So, today, we play a game named "cutting trees". A "rooted tree" is a graph with a distinguished vertex called the root, with the property that from every vertex there is unique path(that doesn't repeat edges) to the root. Essentially this means there are no cycles. Of course, in the game "cutting trees", there are several trees.Again, a move consisits of selecting a tree and hacking away any segment and removing segment and anything not connected to the ground. The player who cuts the last segment wins the game. Input Standard input will contain multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each case begins with a N(1<=N<=1000), the number of trees in the game.A tree is decribed by a number m, the nodes of the tree and R(0<=R<=m1), the root of the tree. Then m1 lines follow, each line containg two positive integers A,B∈[0,m1], means that there is a edge between A and B. In the game, the first player always moves first. Output Results should be directed to standard output. For each case, if the first player wins, ouput "The first player wins", or else, output "The second player wins",in a single line. Sample Input 1 1 4 0 0 1 1 2 1 3 Sample Output The first player wins
 Crash and Go(relians) 怎么实现的
 Problem Description The Gorelians are a warlike race that travel the universe conquering new worlds as a form of recreation. Generally, their space battles are fairly onesided, but occasionally even the Gorelians get the worst of an encounter. During one such losing battle, the Gorelians’ space ship became so damaged that the Gorelians had to evacuate to the planet below. Because of the chaos (and because escape pods are not very accurate) the Gorelians were scattered across a large area of the planet (yet a small enough area that we can model the relevant planetary surface as planar, not spherical). Your job is to track their efforts to regroup. Fortunately, each escape pod was equipped with a locator that can tell the Gorelian his current coordinates on the planet, as well as with a radio that can be used to communicate with other Gorelians. Unfortunately, the range on the radios is fairly limited according to how much power one has. When a Gorelian lands on the alien planet, the first thing he does is check the radio to see if he can communicate with any other Gorelians. If he can, then he arranges a meeting point with them, and then they converge on that point. Once together, they are able to combine the power sources from their radios, which gives them a larger radio range. They then repeat the process—see who they can reach, arrange a meeting point, combine their radios—until they finally cannot contact any more Gorelians. Gorelian technology allows twoway communication as long as at least one of them has a radio with enough range to cover the distance between them. For example, suppose Alice has a radio with a range of 40 km, and Bob has a range of 30 km, but they are 45 km apart (Figure 1). Since neither has a radio with enough range to reach the other, they cannot talk. However, suppose they were only 35 km apart (Figure 2). Bob’s radio still does not have enough range to reach Alice, but that does not matter—they can still talk because Alice’s radio has enough range to reach Bob. If a Gorelian successfully contacts other Gorelians, they will meet at the point that is the average of all their locations. In the case of Alice and Bob, this would simply be the midpoint of A and B (Figure 3). Note that the Gorelians turn off their radios while traveling; they will not attempt to communicate with anyone else until they have all gathered at the meeting point. Once the Gorelians meet, they combine their radios to make a new radio with a larger range. In particular, the area covered by the new radio is equal to the sum of the areas covered by the old radio. In our example, Alice had a range of 40 km, so her radio covered an area of 1600π km. Bob’s radio covered an area of 900π km. So when they combine their radios they can cover 2500π km—meaning they have a range of 50 km. At this point they will try again to contact other Gorelians. This process continues until no more Gorelians can be contacted. As an example, suppose the following Gorelians have all landed and all have a radio range of 30 km: Alice (100, 100), Bob (130, 80), Cathy (80, 60), and Dave (120, 150). At this point, none of the Gorelians can contact anyone else (Figure 5). Now Eddy lands at position (90, 80) (Figure 6). Eddy can contact Alice and Cathy, so they arrange to meet at (90, 80), which is the average of their locations. Combining their radios gives them a range of √2700 ≈ 51.96 km (Figure 7). Now they check again with their new improved range and find that they can reach Bob. So they meet Bob at (110, 80) and combine their radios to get a new radio with a range of 60 (Figure 8). Unfortunately, this is not far enough to be able to reach Dave, so Dave remains isolated. Input The input will consist of one or more data sets. Each data set will begin with an integer N representing the number of Gorelians for this dataset (1 ≤ N ≤ 100). A value of N = 0 will signify the end of the input. Next will come N lines each containing three integers X, Y, and R representing the x and ycoordinate where the Gorelian lands and the range of the radio (0 ≤ X ≤ 1000, 0 ≤ Y ≤ 1000, and 1 ≤ R ≤ 1000). Note that only the Gorelians' initial coordinates/range will be integral; after merging with other Gorelians they may no longer be integral. You should use doubleprecision arithmetic for all computations. The Gorelians land in the order in which they appear in the input file. When a Gorelian lands, he merges with any Gorelians he can contact, and the process keeps repeating until no further merges can be made. The next Gorelian does not land until all previous merges have been completed. Output The output will be one line per data set, reporting the number of independent groups of Gorelians that remain at the end of the process. Sample Input 5 100 100 30 130 80 30 80 60 30 120 150 30 90 80 30 6 100 100 50 145 125 10 60 140 15 160 145 20 130 135 25 80 80 30 0 Sample Output 2 3
 Calling Extraterrestrial Intelligence Again
 Problem Description A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon of Saturday November 16, 1974. The message consisted of 1679 bits and was meant to be translated to a rectangular picture with 23 * 73 pixels. Since both 23 and 73 are prime numbers, 23 * 73 is the unique possible size of the translated rectangular picture each edge of which is longer than 1 pixel. Of course, there was no guarantee that the receivers would try to translate the message to a rectangular picture. Even if they would, they might put the pixels into the rectangle incorrectly. The senders of the Arecibo message were optimistic. We are planning a similar project. Your task in the project is to find the most suitable width and height of the translated rectangular picture. The term "most suitable" is defined as follows. An integer m greater than 4 is given. A positive fraction a / b less than or equal to 1 is also given. The area of the picture should not be greater than m. Both of the width and the height of the translated picture should be prime numbers. The ratio of the width to the height should not be less than a / b nor greater than 1. You should maximize the area of the picture under these constraints. In other words, you will receive an integer m and a fraction a / b. It holds that m > 4 and 0 < a / b < 1. You should find the pair of prime numbers p, q such that pq <= m and a / b <= p / q <= 1, and furthermore, the product pq takes the maximum value among such pairs of two prime numbers. You should report p and q as the "most suitable" width and height of the translated picture. Input The input is a sequence of at most 2000 triplets of positive integers, delimited by a space character in between. Each line contains a single triplet. The sequence is followed by a triplet of zeros, 0 0 0, which indicated the end of the input and should not be treated as data to be processed. The integers of each input triplet are the integer m, the numerator a, and the denominator b described above, in this order. You may assume 4 < m <= 100000 and 1 <= a <= b <= 1000. Output The output is a sequence of pairs of positive integers. The ith output pair corresponds to the ith input triplet. The integers of each output pair are the width p and the height q described above, in this order. Each output line contains a single pair. A space character is put between the integers as a delimiter. No other characters should appear in the output. Sample Input 5 1 2 99999 999 999 1680 5 16 1970 1 1 2002 4 11 0 0 0 Sample Output 2 2 313 313 23 73 43 43 37 53
 Vive la Difference! 具体怎么写的呢
 Problem Description Take any four positive integers: a, b, c, d. Form four more, like this: ab bc cd da That is, take the absolute value of the differences of a with b, b with c, c with d, and d with a. (Note that a zero could crop up, but they’ll all still be nonnegative.) Then, do it again with these four new numbers. And then again. And again. Eventually, all four integers will be the same. For example, start with 1,3,5,9: 1 3 5 9 2 2 4 8 (1) 0 2 4 6 (2) 2 2 2 6 (3) 0 0 4 4 (4) 0 4 0 4 (5) 4 4 4 4 (6) In this case, the sequence converged in 6 steps. It turns out that in all cases, the sequence converges very quickly. In fact, it can be shown that if all four integers are less than 2^n, then it will take no more than 3*n steps to converge! Given a, b, c and d, figure out just how quickly the sequence converges. Input There will be several test cases in the input. Each test case consists of four positive integers on a single line (1 ≤ a,b,c,d ≤ 2,000,000,000), with single spaces for separation. The input will end with a line with four 0s. Output For each test case, output a single integer on its own line, indicating the number of steps until convergence. Output no extra spaces, and do not separate answers with blank lines. Sample Input 1 3 5 9 4 3 2 1 1 1 1 1 0 0 0 0 Sample Output 6 4 0
 Misaki's Kiss again
 Problem Description After the Ferries Wheel, many friends hope to receive the Misaki's kiss again,so Misaki numbers them 1,2...N−1,N,if someone's number is M and satisfied the GCD(N,M) equals to N XOR M,he will be kissed again. Please help Misaki to find all M(1<=M<=N). Note that: GCD(a,b) means the greatest common divisor of a and b. A XOR B means A exclusive or B Input There are multiple test cases. For each testcase, contains a integets N(0<N<=1010) Output For each test case, first line output Case #X:, second line output k means the number of friends will get a kiss. third line contains k number mean the friends' number, sort them in ascending and separated by a space between two numbers Sample Input 3 5 15 Sample Output Case #1: 1 2 Case #2: 1 4 Case #3: 3 10 12 14
 Contour Tracing 反跟踪问题
 Problem Description In computer vision, objects of interest are often represented as regions of 1's in a binary image (bitmap). An important task in the identification of objects is to trace the contour (also called border and boundary) in an object. We assume that the bitmap does not contain any 1's on the borders. To trace the contour of a single object, we can use a procedure known as the Moore boundary tracking algorithm as follows: Scan from the top row to the bottom row, from left to right in each row, until an object pixel is found. Call this object pixel b0, and its west background neighbour c0. Examine the 8 neighbours of b0, starting at c0 and proceeding in clockwise direction. Let b1 denote the first neighbour object pixel encountered, and c1 be the background neighbour immediately preceeding b1. Store the locations of b0 and b1, and append b0 and b1 to the contour. Let b = b1 and c = c1 Let the 8 neighbours of b, starting at c and proceeding in a clockwise direction, be denoted as n1, n2, ..., n8. Find the first object neighbour nk in this sequence. Let b = nk, c = n(k1). Append b to the contour. Repeat steps 4 and 5 until b = b0 and the next contour point found is b1. The last two points b0 and b1 are repeated and should not be appended to the contour again. The first steps of the algorithm is illustrated in the figure below (only the pixels on the boundary are labelled 1 in this bitmap): In this problem, you will be given a bitmap with at most 200 rows and 200 columns. The bitmap contains a number of objects. You are to determine the length of the contour for each object in the bitmap using the procedure above. In the bitmap, a pixel intensity of 0 represents the background, and a pixel intensity of 1 represents an object pixel. Two pixels with intensity 1 belong to the same object if there is a path from one pixel to another consisting of only 1's, and the path is allowed to follow in any of the 8 compass directions. The borders of the bitmap (first row, last row, first column, last column) contain only background pixels. Any object consisting of fewer than 5 pixels should be ignored as it is most likely noise. None of the objects in the bitmap has holes. Equivalently, there exists a path of background pixels following only the 4 main compass directions (N, S, E, W) for every pair of background pixels in the bitmap. Input The input consists of a number of cases. Each case starts with two positive integers on a line, indicating the number of rows (R) and the number of columns (C) in the bitmap. The bitmap is given in the following R lines each containing a string of 0's and 1's of length C. The input is terminated by a case starting with R = C = 0. The last case should not be processed. Output For each case, print the case number on its own line. In the next line, print the lengths of the contours of all objects found in the bitmap, sorted in ascending order. Separate the contour lengths by a single space on that line. If the bitmap has no object that have at least 5 pixels, output the line 'no objects found' instead. Sample Input 7 7 0000000 0011110 0111100 0011100 0111100 0111100 0000000 16 7 0000000 0011110 0111100 0011100 0111100 0111100 0000000 0011000 0100110 0000000 0001000 0010100 0010000 0111000 0111000 0000000 4 4 0000 0000 0010 0000 0 0 Sample Output Case 1 14 Case 2 8 12 14 Case 3 no objects found
 Farey Sequence Again 的过程的编程
 Problem Description The Farey sequence Fn for any positive integer n is the set of irreducible rational numbers a/b with 0<a<b<=n and (a, b) = 1 arranged in increasing order. Here (a, b) mean the greatest common divisor of a and b. For example: F2 = {1/2} F3 = {1/3, 1/2, 2/3} Given two positive integers N and K, with K less than N, you need to find out the Kth smallest element of the Farey sequence FN. Input The first line of input is the number of test case T, 1<=T<=1000. Then each test case contains two positive integers N and K. 1<=K<N<=10^9. Output For each test case output the Kth smallest element of the Farey sequence FN in a single line. Sample Input 3 2 1 100 68 101 69 Sample Output 1/2 2/83 1/42
 Persistent Bits 实现
 Problem Description WhatNext Software creates sequence generators that they hope will produce fairly random sequences of 16bit unsigned integers in the range 0–65535. In general a sequence is specified by integers A, B, C, and S, where 1 ≤ A < 32768, 0 ≤ B < 65536, 2 ≤ C < 65536, and 0 ≤ S < C. S is the first element (the seed) of the sequence, and each later element is generated from the previous element. If X is an element of the sequence, then the next element is (A * X + B) % C where '%' is the remainder or modulus operation. Although every element of the sequence will be a 16bit unsigned integer less than 65536, the intermediate result A * X + B may be larger, so calculations should be done with a 32bit int rather than a 16bit short to ensure accurate results. Some values of the parameters produce better sequences than others. The most embarrassing sequences to WhatNext Software are ones that never change one or more bits. A bit that never changes throughout the sequence is persistent. Ideally, a sequence will have no persistent bits. Your job is to test a sequence and determine which bits are persistent. For example, a particularly bad choice is A = 2, B = 5, C = 18, and S = 3. It produces the sequence 3, (2*3+5)%18 = 11, (2*11+5)%18 = 9, (2*9+5)%18 = 5, (2*5+5)%18 = 15, (2*15+5)%18 = 17, then (2*17+5)%18 = 3 again, and we're back at the beginning. So the sequence repeats the the same six values over and over: Decimal 16Bit Binary 3 0000000000000011 11 0000000000001011 9 0000000000001001 5 0000000000000101 15 0000000000001111 17 0000000000010001 overall 00000000000????1 The last line of the table indicates which bit positions are always 0, always 1, or take on both values in the sequence. Note that 12 of the 16 bits are persistent. (Good random sequences will have no persistent bits, but the converse is not necessarily true. For example, the sequence defined by A = 1, B = 1, C = 64000, and S = 0 has no persistent bits, but it's also not random: it just counts from 0 to 63999 before repeating.) Note that a sequence does not need to return to the seed: with A = 2, B = 0, C = 16, and S = 2, the sequence goes 2, 4, 8, 0, 0, 0, .... Input There are from one to sixteen datasets followed by a line containing only 0. Each dataset is a line containing decimal integer values for A, B, C, and S, separated by single blanks. Output There is one line of output for each data set, each containing 16 characters, either '1', '0', or '?' for each of the 16 bits in order, with the most significant bit first, with '1' indicating the corresponding bit is always 1, '0' meaning the corresponding bit is always 0, and '?' indicating the bit takes on values of both 0 and 1 in the sequence. Sample Input 2 5 18 3 1 1 64000 0 2 0 16 2 256 85 32768 21845 1 4097 32776 248 0 Sample Output 00000000000????1 ???????????????? 000000000000???0 0101010101010101 0???000011111???
 Extraordinarily Tired Students
 Problem Description When a student is too tired, he can't help sleeping in class, even if his favorite teacher is right here in front of him. Imagine you have a class of extraordinarily tired students, how long do you have to wait, before all the students are listening to you and won't sleep any more? In order to complete this task, you need to understand how students behave. When a student is awaken, he struggles for a minutes listening to the teacher (after all, it's too bad to sleep all the time). After that, he counts the number of awaken and sleeping students (including himself). If there are strictly more sleeping students than awaken students, he sleeps for b minutes. Otherwise, he struggles for another a minutes, because he knew that when there is only very few sleeping students, there is a big chance for them to be punished! Note that a student counts the number of sleeping students only when he wants to sleep again. Now that you understand each student could be described by two integers a and b, the length of awaken and sleeping period. If there are always more sleeping students, these two periods continue again and again. We combine an awaken period with a sleeping period after it, and call the combined period an awakensleeping period. For example, a student with a=1 and b=4 has an awakensleeping period of awakensleepingsleepingsleepingsleeping. In this problem, we need another parameter c (1 ≤ c ≤ a+b) to describe a student's initial condition: the initial position in his awakensleeping period. The 1st and 2nd position of the period discussed above are awaken and sleeping, respectively. Now we use a triple (a, b, c) to describe a student. Suppose there are three students (2, 4, 1), (1, 5, 2) and (1, 4, 3), all the students will be awaken at time 18. The details are shown in the table below. Write a program to calculate the first time when all the students are not sleeping. Input The input consists of several test cases. The first line of each case contains a single integer n (1 ≤ n ≤ 10), the number of students. This is followed by n lines, each describing a student. Each of these lines contains three integers a, b, c (1 ≤ a, b ≤ 5), described above. The last test case is followed by a single zero, which should not be processed. Output For each test case, print the case number and the first time all the students are awaken. If it'll never happen, output 1. Sample Input 3 2 4 1 1 5 2 1 4 3 3 1 2 1 1 2 2 1 2 3 0 Sample Output Case 1: 18 Case 2: 1
 c语言编程 输入两个加数并计算结果，正确输出对，错误输出错，直道算对为止
 为什么我这个程序，计算错误还能继续计算，一旦计算正确就崩溃了呢，求大神帮帮我 #include <stdio.h> int Addtest(int a，int b) { int answer; printf("％d+％d=",a,b）； scanf("％d",&answer); if(a＋b==answer) return 1； else return 0; } void Print (int flag） { if(flag) printf("Right\n"）； else printf ("Notcorrect Try again\n"）； } main() { int a,b, answer; printf ("Input a,b"）； scanf ("％d,％d",&a,&b）； do{ answer=Addtest(a,b)； printf(answer); }while(answer==0); }
 Let's play UNO
 Problem Description Uno is a famous card game played with a specially printed deck. It's very popular as a funny game in a party. A socalled "official rules" is presented at the Wikipedia, but there are a lot of different extended rules all over the world according to their specific needs. In this problem, you are required to obey our rules introduced below: The Uno deck consists of cards of 4 colors: red(R), green(G), blue(B), and yellow(Y). Each color has two kinds of cards, number cards and action cards. The ranks in number cards are 09. There are 3 "action" cards in each color, labeled "skip"(S), "draw two"(D), and "reverse"(R). The functions of the actions will be described afterwards. For each color, there are two copies of each positive number card and action card, but only one zero card, producing 25 cards in total. Besides, there are also special black action cards called "wild cards", "wild"(WC) and "wild draw four"(WF). There are four "wild" and "wild draw four" cards each. Hence, there are 108 cards in total. In this problem, a card is marked with an ID of two characters length, the first is the color (R, G, B, Y, W) while the second is the rank (09, S, D, R, C, F). For example, the ID of red 2 is R2, the yellow reverse is YR, the wild cards are WC and WF. Supposed there are n players numbered from 1 to n clockwise. Before playing, players take turns(in the order of 1, 2, ... n) to pick seven successive cards from the stock. The top card of the remaining stock is exposed to start the game, treated as if player 1 dropped that card. The exposed card will never be WC or WF in this problem. Then the game begins clockwise (next player is 2), or counterclockwise (next player is n) if the top exposed card is a reverse. At each turn, a player may drop a card from their hand that matches the color or rank of the top exposed card (e.g., if the top card is R3, you can drop R5 or G3; if the top card is RD, you can drop R3 or GD) or play a WC. What's more, if the player has a WF and no other legal cards to drop, he can drop the WF. Then the card dropped just now becomes the top exposed card. If a player has no legal cards, he must draw the top card of the stock and place it in his hand. After dropping a single card or drawing, the next player clockwise takes a turn, or counterclockwise when the reverse is in effect. When a player drops down to only one card, that player is required to say "uno" to warn other players. The game ends when a player drops all his/her cards, or the stock is emptied but the current player has to draw a card. If the last card is an action card, the special effect still occurs. When the game ends, all players count the number of points pertaining to the values of the cards in their hands. Number cards worth the face value on them, colored special cards worth twenty, and wilds worth fifty, e.g., R2 worth 2, G0 worth 0, BD and YS worth 20, WC and WF worth 50. The descriptions of the action cards: Now here comes the problem. There are N people playing Uno under the rules mentioned above. Given the sequence of the 108 cards of the stock, you are asked to simulate a Uno game. At each turn, the player will always drop a card if permitted. If there are more than one choices, the player will drop the card with the largest point. If still a tie, he will choose the one whose ID is the smallest alphabetical order. When a player drops WC or WF, he has to name a color. The first time he will name red, the second time he will name green, the third time blue, the fourth time yellow, the fifth time red again, and so on. When the game ends, you should output the final score of each player, and we also want to know how many times each player calls "Uno". Input The first line of the input file contains a single number: the number of test cases to follow. Each test case has two lines: The first line contains the number of players N , with 2<=N<=10. The second line contains 108 IDs of the Uno cards, separated by one space. Each ID is two characters long as introduced in the description above. Output For each test case, output two lines: The first line are N integers, the ith integer is the final score of player i. The second lines are also N integers, the ith integer shows how many times player i calls "Uno". Sample Input 1 2 R9 RD RD RS RS RR RR B0 B1 B1 B2 B2 B3 B3 G0 GD GD GS GS GR GR G9 G9 G8 G8 G7 G7 G6 G6 G5 G5 G4 G4 G3 G3 G2 G2 G1 G1 Y0 Y9 Y9 Y8 Y8 Y7 Y7 Y6 Y6 Y5 Y5 Y4 Y4 Y3 Y3 Y2 Y2 Y1 Y1 YD YD YS YS YR YR R9 R8 R8 R7 R7 R6 R6 R5 R5 R4 R4 R3 R3 R2 R2 R1 R1 R0 B4 B4 B5 B5 B6 B6 B7 B7 B8 B8 B9 B9 BD BD BS BS BR BR WC WC WC WC WF WF WF WF Sample Output 249 0 0 1
 Cutting trees 设计的问题
 Problem Description A rooted graph is an indirected graph with every edge attached by some path to a special vertex called the root or the ground. The ground is denoted in the below figures that follow by a dotted line. A bamboo stalk with n segments is a linear graph of n edges with the bottom of the n edges rooted to the ground. A move consists of hacking away one of the segments, and removing that segment and all segments above it no longer connectd to the ground. Two players alternate moves and the last player to move wins. A single bamboo stalk of n segments can be moved into a bamboo stalk of any smaller number of segments from n1 to 0. So a single bamboo stalk of n segments is equivalent to a nim pile of n chips. As you known, the player who moves first can win the the game with only one bamboo stalk. So many people always play the game with several bamboo stalks. One example is as below: Playing a sum of games of bamboo stalks is thus equivalent to playing a nim game that with several piles. A move consisits of selecting a bamboo stalk containg n segments and hacking away one of the segments in the selected bamboo stalk. I think the nim game is easy for you, the smart ACMers. So, today, we play a game named "cutting trees". A "rooted tree" is a graph with a distinguished vertex called the root, with the property that from every vertex there is unique path(that doesn't repeat edges) to the root. Essentially this means there are no cycles. Of course, in the game "cutting trees", there are several trees.Again, a move consisits of selecting a tree and hacking away any segment and removing segment and anything not connected to the ground. The player who cuts the last segment wins the game. Input Standard input will contain multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each case begins with a N(1<=N<=1000), the number of trees in the game.A tree is decribed by a number m, the nodes of the tree and R(0<=R<=m1), the root of the tree. Then m1 lines follow, each line containg two positive integers A,B∈[0,m1], means that there is a edge between A and B. In the game, the first player always moves first. Output Results should be directed to standard output. For each case, if the first player wins, ouput "The first player wins", or else, output "The second player wins",in a single line. Sample Input 1 1 4 0 0 1 1 2 1 3 Sample Output The first player wins
 爬虫福利二 之 妹子图网MM批量下载
 爬虫福利一：27报网MM批量下载 点击 看了本文，相信大家对爬虫一定会产生强烈的兴趣，激励自己去学习爬虫，在这里提前祝：大家学有所成！ 目标网站：妹子图网 环境：Python3.x 相关第三方模块：requests、beautifulsoup4 Re：各位在测试时只需要将代码里的变量path 指定为你当前系统要保存的路径，使用 python xxx.py 或IDE运行即可。 ...
 Java学习的正确打开方式
 在博主认为，对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结，前三者博主将淋漓尽致地挥毫于这篇博客文章中，至于总结在于个人，实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍，博客次之，这又是一个层次了，这里暂时不提后面再谈。博主将为各位入门java保驾护航，各位只管冲鸭！！！上天是公平的，只要不辜负时间，时间自然不会辜负你。 何谓学习？博主所理解的学习，它是一个过程，是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
 大学四年自学走来，这些私藏的实用工具/学习网站我贡献出来了
 大学四年，看课本是不可能一直看课本的了，对于学习，特别是自学，善于搜索网上的一些资源来辅助，还是非常有必要的，下面我就把这几年私藏的各种资源，网站贡献出来给你们。主要有：电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意：文中提到的所有资源，文末我都给你整理好了，你们只管拿去，如果觉得不错，转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
 linux系列之常用运维命令整理笔录
 本博客记录工作中需要的linux运维命令，大学时候开始接触linux，会一些基本操作，可是都没有整理起来，加上是做开发，不做运维，有些命令忘记了，所以现在整理成博客，当然vi，文件操作等就不介绍了，慢慢积累一些其它拓展的命令，博客不定时更新 free m 其中：m表示兆，也可以用g，注意都要小写 Men：表示物理内存统计 total：表示物理内存总数(total=used+free) use...
 比特币原理详解
 一、什么是比特币 比特币是一种电子货币，是一种基于密码学的货币，在2008年11月1日由中本聪发表比特币白皮书，文中提出了一种去中心化的电子记账系统，我们平时的电子现金是银行来记账，因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述，这一层面介绍的文章很多，本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
 程序员接私活怎样防止做完了不给钱？
 首先跟大家说明一点，我们做 IT 类的外包开发，是非标品开发，所以很有可能在开发过程中会有这样那样的需求修改，而这种需求修改很容易造成扯皮，进而影响到费用支付，甚至出现做完了项目收不到钱的情况。 那么，怎么保证自己的薪酬安全呢？ 我们在开工前，一定要做好一些证据方面的准备（也就是“讨薪”的理论依据），这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
 网页实现一个简单的音乐播放器（大佬别看。(⊙﹏⊙)）
 今天闲着无事，就想写点东西。然后听了下歌，就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; textdecoration: none; list...
 Python十大装B语法
 Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。
 数据库优化  SQL优化
 以实际SQL入手，带你一步一步走上SQL优化之路！
 2019年11月中国大陆编程语言排行榜
 2019年11月2日，我统计了某招聘网站，获得有效程序员招聘数据9万条。针对招聘信息，提取编程语言关键字，并统计如下： 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
 通俗易懂地给女朋友讲：线程池的内部原理
 餐盘在灯光的照耀下格外晶莹洁白，女朋友拿起红酒杯轻轻地抿了一小口，对我说：“经常听你说线程池，到底线程池到底是个什么原理？”
 经典算法（5）杨辉三角
 杨辉三角 是经典算法，这篇博客对它的算法思想进行了讲解，并有完整的代码实现。
 腾讯算法面试题：64匹马8个跑道需要多少轮才能选出最快的四匹？
 昨天，有网友私信我，说去阿里面试，彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static？他被难住了，因为他从来都没有考虑过这个问题。无独有偶，今天笔者又发现有网友吐槽了一道腾讯的面试题，我们一起来看看。 腾讯算法面试题：64匹马8个跑道需要多少轮才能选出最快的四匹？ 在互联网职场论坛，一名程序员发帖求助到。二面腾讯，其中一个算法题：64匹...
 面试官：你连RESTful都不知道我怎么敢要你？
 干货，2019 RESTful最贱实践
 JDK12 Collectors.teeing 你真的需要了解一下
 前言 在 Java 12 里面有个非常好用但在官方 JEP 没有公布的功能，因为它只是 Collector 中的一个小改动，它的作用是 merge 两个 collector 的结果，这句话显得很抽象，老规矩，我们先来看个图(这真是一个不和谐的图????): 管道改造经常会用这个小东西，通常我们叫它「三通」，它的主要作用就是将 downstream1 和 downstre...
 为啥国人偏爱Mybatis，而老外喜欢Hibernate/JPA呢？
 关于SQL和ORM的争论，永远都不会终止，我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论，感触还是有一些，于是就有了今天这篇文。 声明：本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实，讲道理，所以，请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题，争论已经很多年了。一直也没有结论，毕竟每个人的喜好和习惯是大不相同的。我也看...
 SQL小白最佳入门sql查询一
 不要偷偷的查询我的个人资料，即使你再喜欢我，也不要这样，真的不好；
 项目中的if else太多了，该怎么重构？
 介绍 最近跟着公司的大佬开发了一款IM系统，类似QQ和微信哈，就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
 【图解经典算法题】如何用一行代码解决约瑟夫环问题
 约瑟夫环问题算是很经典的题了，估计大家都听说过，然后我就在一次笔试中遇到了，下面我就用 3 种方法来详细讲解一下这道题，最后一种方法学了之后保证让你可以让你装逼。 问题描述：编号为 1N 的 N 个士兵围坐在一起形成一个圆圈，从编号为 1 的士兵开始依次报数（1，2，3…这样依次报），数到 m 的 士兵会被杀死出列，之后的士兵再从 1 开始报数。直到最后剩下一士兵，求这个士兵的编号。 1、方...
 致 Python 初学者
 欢迎来到“Python进阶”专栏！来到这里的每一位同学，应该大致上学习了很多 Python 的基础知识，正在努力成长的过程中。在此期间，一定遇到了很多的困惑，对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言，从2009年开始单一使用 python 应对所有的开发工作，直至今天。回顾自己的学习过程，也曾经遇到过无数的困难，也曾经迷茫过、困惑过。开办这个专栏，正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
 “狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作
 一、垃圾文字生成器介绍 最近在浏览GitHub的时候，发现了这样一个骨骼清奇的雷人项目，而且热度还特别高。 项目中文名：狗屁不通文章生成器 项目英文名：BullshitGenerator 根据作者的介绍，他是偶尔需要一些中文文字用于GUI开发时测试文本渲染，因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理，所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的： 你发现，...
 程序员：我终于知道post和get的区别
 是一个老生常谈的话题，然而随着不断的学习，对于以前的认识有很多误区，所以还是需要不断地总结的，学而时习之，不亦说乎
 GitHub标星近1万：只需5秒音源，这个网络就能实时“克隆”你的声音
 作者  Google团队 译者  凯隐 编辑  Jane 出品  AI科技大本营（ID：rgznai100） 本文中，Google 团队提出了一种文本语音合成（text to speech）神经系统，能通过少量样本学习到多个不同说话者（speaker）的语音特征，并合成他们的讲话音频。此外，对于训练时网络没有接触过的说话者，也能在不重新训练的情况下，仅通过未知...
 《程序人生》系列这个程序员只用了20行代码就拿了冠军
 你知道的越多，你不知道的越多 点赞再看，养成习惯GitHub上已经开源https://github.com/JavaFamily，有一线大厂面试点脑图，欢迎Star和完善 前言 这一期不算《吊打面试官》系列的，所有没前言我直接开始。 絮叨 本来应该是没有这期的，看过我上期的小伙伴应该是知道的嘛，双十一比较忙嘛，要值班又要去帮忙拍摄年会的视频素材，还得搞个程序员一天的Vlog，还要写BU...
 加快推动区块链技术和产业创新发展，2019可信区块链峰会在京召开
 11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 1...
 程序员把地府后台管理系统做出来了，还有3.0版本！12月7号最新消息：已在开发中有github地址
 第一幕：缘起 听说阎王爷要做个生死簿后台管理系统，我们派去了一个程序员…… 996程序员做的梦： 第一场：团队招募 为了应对地府管理危机，阎王打算找“人”开发一套地府后台管理系统，于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好，地府都是满格，哈哈！！！ 经常会有外行朋友问：看某网站做的不错，功能也简单，你帮忙做一下？ 而这次，面对这样的需求，这个程序员...
 网易云6亿用户音乐推荐算法
 网易云音乐是音乐爱好者的集聚地，云音乐推荐系统致力于通过 AI 算法的落地，实现用户千人千面的个性化推荐，为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践，以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开： AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今，网易云音乐平台持续提供着：乐屏社区、UGC...
 【技巧总结】位运算装逼指南
 位算法的效率有多快我就不说，不信你可以去用 10 亿个数据模拟一下，今天给大家讲一讲位运算的一些经典例子。不过，最重要的不是看懂了这些例子就好，而是要在以后多去运用位运算这些技巧，当然，采用位运算，也是可以装逼的，不信，你往下看。我会从最简单的讲起，一道比一道难度递增，不过居然是讲技巧，那么也不会太难，相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数，相信很多人都做过，一般的做法的代码如下...
 【管理系统课程设计】美少女手把手教你后台管理
 【文章后台管理系统】URL设计与建模分析+项目源码+运行界面 栏目管理、文章列表、用户管理、角色管理、权限管理模块（文章最后附有源码） 1. 这是一个什么系统? 1.1 学习后台管理系统的原因 随着时代的变迁，现如今各大云服务平台横空出世，市面上有许多如学生信息系统、图书阅读系统、停车场管理系统等的管理系统，而本人家里就有人在用烟草销售系统，直接在网上完成挑选、购买与提交收货点，方便又快捷。 试想，若没有烟草销售系统，本人家人想要购买烟草，还要独自前往药...
 4G EPS 第四代移动通信系统
 目录 文章目录目录4G 与 LTE/EPCLTE/EPC 的架构EUTRANEUTRAN 协议栈eNodeBEPCMMESGWPGWHSSLTE/EPC 协议栈概览 4G 与 LTE/EPC 4G，即第四代移动通信系统，提供了 3G 不能满足的无线网络宽带化，主要提供数据（上网）业务。而 LTE（Long Term Evolution，长期演进技术）是电信领域用于手机及数据终端的高速无线通...
 日均350000亿接入量，腾讯TubeMQ性能超过Kafka
 整理  夕颜出品  AI科技大本营（ID:rgznai100）【导读】近日，腾讯开源动作不断，相继开源了分布式消息中间件TubeMQ，基于最主流的 OpenJDK8开发的Tencent Kona JDK，分布式HTAP数据库 TBase，企业级容器平台TKEStack，以及高性能图计算框架Plato。短短一周之内，腾讯开源了五大重点项目。其中，TubeMQ是腾讯大数据平台部门应用的核心组件，...