 Unknown Treasure

Problem Description
On the way to the next secret treasure hiding place, the mathematician discovered a cave unknown to the map. The mathematician entered the cave because it is there. Somewhere deep in the cave, she found a treasure chest with a combination lock and some numbers on it. After quite a research, the mathematician found out that the correct combination to the lock would be obtained by calculating how many ways are there to pick m different apples among n of them and modulo it with M. M is the product of several different primes.Input
On the first line there is an integer T(T≤20) representing the number of test cases.Each test case starts with three integers n,m,k(1≤m≤n≤1018,1≤k≤10) on a line where k is the number of primes. Following on the next line are k different primes p1,...,pk. It is guaranteed that M=p1⋅p2⋅⋅⋅pk≤1018 and pi≤105 for every i∈{1,...,k}.
Output
For each test case output the correct combination on a line.Sample Input
1
9 5 2
3 5Sample Output
6
 其他相关推荐
 Treasure Division 怎么写
 Problem Description Ant Tony and Monkey Luffy have discovered a big treasure.It turns out to be a box of gold coins.There are N gold coins in the box.However,the gold coins are not all the same.Every gold coin has a value Vi.Now they wants to divide this big treasure into two halves.The number of gold coin differ in two half must be no more than one.Tony and Luffy wants to know the fairest division,ie,the division which minimize the difference between each parts. Input Input contains multiple cases.Test cases are separated by several blank lines. Each test case starts with a integer N(1<=N<=30) ,indicating that there are N gold coins int the treasure box.Followed by one line contain N integer,the ith integer vi (1<=vi<=2^30),representing the value of coin i. Output For each case,output the least difference that could be found in one fairest division. Sample Input 3 2 2 4 4 1 2 3 6 Sample Output 0 2
 Treasure of the Chimp Island
 Problem Description Bob Bennett, the young adventurer, has found the map to the treasure of the Chimp Island, where the ghost zombie pirate LeChimp, the infamous evil pirate of the Caribbeans has hidden somewhere inside the Zimbu Memorial Monument (ZM2). ZM2 is made up of a number of corridors forming a maze. To protect the treasure, LeChimp has placed a number of stone blocks inside the corridors to block the way to the treasure. The map shows the hardness of each stone block which determines how long it takes to destroy the block. ZM2 has a number of gates on the boundary from which Bob can enter the corridors. Fortunately, there may be a pack of dynamites at some gates, so that if Bob enters from such a gate, he may take the pack with him. Each pack has a number of dynamites that can be used to destroy the stone blocks in a much shorter time. Once entered, Bob cannot exit ZM2 and enter again, nor can he walk on the area of other gates (so, he cannot pick more than one pack of dynamites). The hardness of the stone blocks is an integer between 1 and 9, showing the number of days required to destroy the block. We neglect the time required to travel inside the corridors. Using a dynamite, Bob can destroy a block almost immediately, so we can ignore the time required for it too. The problem is to find the minimum time at which Bob can reach the treasure. He may choose any gate he wants to enter ZM2. Input The input consists of multiple test cases. Each test case contains the map of ZM2 viewed from the above. The map is a rectangular matrix of characters. Bob can move in four directions up, down, left, and right, but cannot move diagonally. He cannot enter a location shown by asterisk characters (*), even using all his dynamites! The character ($) shows the location of the treasure. A digit character (between 1 and 9) shows a stone block of hardness equal to the value of the digit. A hash sign (#) which can appear only on the boundary of the map indicates a gate without a dynamite pack. An uppercase letter on the boundary shows a gate with a pack of dynamites. The letter A shows there is one dynamite in the pack, B shows there are two dynamite in the pack and so on. All other characters on the boundary of the map are asterisks. Corridors are indicated by dots (.). There is a blank line after each test case. The width and the height of the map are at least 3 and at most 100 characters. The last line of the input contains two dash characters (). Output For each test case, write a single line containing a number showing the minimum number of days it takes Bob to reach the treasure, if possible. If the treasure is unreachable, write IMPOSSIBLE. Sample Input *****#********* *.1....4..$...* *..***..2.....* *..2..*****..2* *..3..******37A *****9..56....* *.....******..* ***CA********** ***** *$3** *.2** ***#*  Sample Output 1 IMPOSSIBLE
 Treasure Division 怎么来分
 Problem Description Ant Tony and Monkey Luffy have discovered a big treasure.It turns out to be a box of gold coins.There are N gold coins in the box.However,the gold coins are not all the same.Every gold coin has a value Vi.Now they wants to divide this big treasure into two halves.The number of gold coin differ in two half must be no more than one.Tony and Luffy wants to know the fairest division,ie,the division which minimize the difference between each parts. Input Input contains multiple cases.Test cases are separated by several blank lines. Each test case starts with a integer N(1<=N<=30) ,indicating that there are N gold coins int the treasure box.Followed by one line contain N integer,the ith integer vi (1<=vi<=2^30),representing the value of coin i. Output For each case,output the least difference that could be found in one fairest division. Sample Input 3 2 2 4 4 1 2 3 6 Sample Output 0 2
 Get The Treasure 的问题
 Problem Description One day, a team of archaeologists found a figure and some ancient charactors at a relique. The figure was made up of n points distributing on a circle symmetrically. After investigating the charactors, they got to know that a treasure was hid beneath the figure. In order to open the door to the treasure, they must redraw all the lines between any two points in the figure with some colors. If the figure was right, the door would open. Now they want to know how many times they have to try at most to open the door, and they ask you for help. Input Each test case contains an integer n and a string S in a line. n is the number of points in the figure and S is a string made up of distinct capital letters, each indicating a color that can be used to redraw the figure. 3 <= n <= 50. Output Each case outputs the maximum times they may try in one line. Note that two figures are considered the same if one can be obtained by having rotation and mirroring on the other one. Sample Input 3 BW 3 RGB 4 RG Sample Output 4 10 19
 Treasure Division 的实现办法
 Problem Description Ant Tony and Monkey Luffy have discovered a big treasure.It turns out to be a box of gold coins.There are N gold coins in the box.However,the gold coins are not all the same.Every gold coin has a value Vi.Now they wants to divide this big treasure into two halves.The number of gold coin differ in two half must be no more than one.Tony and Luffy wants to know the fairest division,ie,the division which minimize the difference between each parts. Input Input contains multiple cases.Test cases are separated by several blank lines. Each test case starts with a integer N(1<=N<=30) ,indicating that there are N gold coins int the treasure box.Followed by one line contain N integer,the ith integer vi (1<=vi<=2^30),representing the value of coin i. Output For each case,output the least difference that could be found in one fairest division. Sample Input 3 2 2 4 4 1 2 3 6 Sample Output 0 2
 Finding Treasure 是怎么实现的呢
 Description Once upon a time, there was a young man who loved adventure. He found an old lambskin in his grandfather's relic which described a secret buried treasure. The old lambskin told him to go to a particular deserted island. There was a big stretch of lawn on the north shore of the island. On the lawn there was an oak tree, a pine tree and a gallows. The instructions were as following: Walk from the gallows to the oak tree and remember the distance, turn right and walk the same distance, and make a mark there. Then return to the gallows, walk towards the pine tree and remember the distance, turn left and walk the same distance, and also make a mark. Excavate at the middle point of the segment between the two marks, and the treasure will be there (see Figure 1). Figure 1 The young man found that island and also found the oak tree and the pine tree, but the gallows was destroyed due to the abrasion of time. The young person was disappointed and went back. What a pity! If the young man had some geometry knowledge, he would discover that the position of the treasure is independent from the position of the gallows. But I believe you will not make similar mistakes. Given a general description of how to find the treasure, your job is to find the position of the treasure, if the position can be fixed. First you will be given some points of original marks. The positions of some of these points are known, but the others are unknown. Then you will be given some instructions to make new marks. There are three kinds of instructions: Given two marks A and B, the new mark is at the middle point between A and B. Given two marks A and B, walk from A to B, turn left, walk the same distance as the distance between A and B, and then make a mark. Given two marks A and B, walk from A to B, turn right, walk the same distance as the distance between A and B, and then make a mark. At last, you will be asked for the position of a mark. Input There are several test cases. Each test case has three parts of input. The first part contains several lines indicating the original marks with the one of the following two formats: M or: M x y Here M is the mark symbol, and x and y are integers in the range of [0, 100]. The first format means that we don't know the position of the mark. The second format means that we know the position of the mark is (x, y). In this part, one mark will be mentioned at most once. The second part contains some instructions with the following formats: N A B C Here N (= 1, 2 or 3) indicates which kind of instruction is used. A, B are symbols of the marks you have already had, and C is the symbol of a new mark you will get. You may assume that A and B are different marks and have been mentioned before, and it's the first time for C to show up. The third part is one line containing a mark symbol, of which we want to know the position. It is assured that this mark has been mentioned before. A line with "END" indicates the end of the input. To make it easier, we use 'A', 'B', ... and 'Z' as mark symbols, which implies there are no more than 26 marks. Output For each test case, output one line containing two decimal numbers x and y, which means (x, y) is the position we want to know. These numbers should be rounded two digits after the decimal point. If the position is uncertain, output "UNCERTAIN!" instead. Sample Input B 0 0 A C 100 0 3 A B D 2 A C E 1 D E F F END Sample Output 50.00 50.00
 The Treasure 什么思路
 Description We have arrived at the age of the Internet. Many software applications have transformed from standalone to online applications. Computer games are following this trend as well. Online games are becoming more and more popular, not only because they are more intelligent, but also because they can bring great profits. "The computer game industry is developing rapidly in China. Online game revenues amounted to 1.3 billion Yuan last year and are expected to reach 6.7 billion Yuan by 2007." reported by China Daily in 2004. However, good games originate from good programmers. We take for example that there is a RPG (Role Playing Game) and your boss asks you to implement some tasks. For simplicity’s sake, we assume there are two kinds of roles in this game: one is player and the other is monster. You should help the player to achieve the goal: reach the place where treasure is positioned as early as possible and get the treasure. The map of the game is a matrix of N * M identical cells. Some cells are passable blocks, and others are nonpassable rocks. At any time, there is at most one role occupying a block. At the beginning, the time is set to 0, and the player is at a certain block. He then moves towards the treasure. At each turn, we have some rules: The player can stay in the same block during the next onesecond time duration, or he can walk or run towards the east, south, west, north, northeast, northwest, southeast, and southwest. With walking, the player can arrive at the corresponding passable blocks around him (See Fig.1). Each move takes 1 second. With running, the player can arrive at the corresponding passable blocks 2 cells away from him (See Fig.2). Each run takes 1 second. As demonstrated in Fig.3, if a neighbor cell is not passable, the player cannot run in that direction. For example, if cell 2 is a rock, running from 1 to 3 is impossible. The monsters are classified into aggressive and nonaggressive. If a monster occupies a cell, the player cannot move into that cell or run through that cell. In addition, the player cannot move into the cells surrounding an aggressive monster, because it will attack the player near it. For example, in Fig.4, if there is an aggressive monster in 5, then the cell 1, 2, 3, 4, 6, 7, 8 and 9 are in its attacking region, so the player cannot stay in or pass through these cells. Monsters change their positions each turn. Each monster appears by its position sequence iteratively. That's to say, given the position sequence of monster i: (x1, y1), (x2, y2), ..., (xs, ys), its initial position is (x1, y1) at time 0, then it appears in (x2, y2) at time 1, and so on. When monster i arrives at (xs, ys) at time s1, it will arrive in (x1, y1) at time s, and start to repeat. At the start of each turn, all the monsters change their positions first (the way of changing is given above). If a monster appears in the player's cell, or if an aggressive monster appears near the player to put him in its attacking region, the player will die, and the goal cannot be achieved. After all the monsters change their positions, the player makes a move or stays in the same cell. In his move, the moving path should not be occupied by any rocks or monsters or in the attacking region of any aggressive monsters. When counting the total time, we can neglect the time between monsters' position change and the player's move. Given the map of the game, the player's starting position, the treasure position and all the monsters' positions in every second, your task is to write a program to find the minimum time that the player gets the treasure. Input The input consists of several test cases. The first line of each case contains two integers N and M (1 <= N, M <= 100), where N is the height of the map and M is the width of the map. This is followed by N lines each containing M characters representing the map. A '#' represents a rock, a '.' is a free block, 'p' is the starting position of the player, 't' is the position of the treasure, 'n' is the initial position of a nonaggressive monster, and an 'a' stands for the initial position of an aggressive monster. The cell (i, j) is the jth cell on the ith row counting from left to right. The rows are counted from 1 to N starting from the first line of the matrix. We can number all the monsters as 1, 2, 3… according to their initial position, sorting first by row, then by column. The (n+2)th line contains an integer p (0 <= p <= 100), which is the total number of monsters (i.e. the total number of 'n's and 'a's in the matrix). It is followed by p lines each specifying a monster's position sequence in the following format: the ith (1 <= i <= p) line corresponds to monster i, which begins with an integer s (1 <= s <= 100), meaning the length of position sequence. Then s pairs of integers x1, y1, x2, y2, …, xs, ys are followed, separated by blanks. Each pair is a free block in the map, (i.e. a monster never goes to a rock cell). It is assured that none of the aggressive monsters' initial position is around the player. Two consecutive cases are separated by a blank line. The input is terminated by a line containing a pair of zeros. Output For each test case, output the minimum total time required for the player to get the treasure, in seconds. If it's not possible to get the treasure, or the minimum required time is greater than 100 seconds, please print a line just containing the string "impossible". Two consecutive cases should be separated by a blank line. Sample Input 7 8 #.#####. #.t#..p. #..#.... ..#a.#.# #...##.n .#...... ........ 2 2 4 4 5 4 3 5 8 6 8 5 7 3 3 p#. ##. t.. 0 2 2 #t p# 0 0 0 Sample Output 8 impossible 1
 Treasure Division 怎么来编程代码
 Problem Description Ant Tony and Monkey Luffy have discovered a big treasure.It turns out to be a box of gold coins.There are N gold coins in the box.However,the gold coins are not all the same.Every gold coin has a value Vi.Now they wants to divide this big treasure into two halves.The number of gold coin differ in two half must be no more than one.Tony and Luffy wants to know the fairest division,ie,the division which minimize the difference between each parts. Input Input contains multiple cases.Test cases are separated by several blank lines. Each test case starts with a integer N(1<=N<=30) ,indicating that there are N gold coins int the treasure box.Followed by one line contain N integer,the ith integer vi (1<=vi<=2^30),representing the value of coin i. Output For each case,output the least difference that could be found in one fairest division. Sample Input 3 2 2 4 4 1 2 3 6 Sample Output 0 2
 Treasure Hunters
 Introduction You've been a treasure hunter for a long time. You're pretty good at disarming traps, sneaking past the natives, and generally getting the goods while leaving your skin intact. That stuff doesn't really worry you, but what really raises a sweat is after each expedition there are always very tense arguments about how to split up the loot. You've worked with all kinds of characters and nobody ever agrees on what each piece of treasure is actually worth. You need to come up with a way of splitting the booty as fairly as possible. Input Input to this problem will consist of a (nonempty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. A single data set has 5 components: Start line  A single line, "START" Number of Treasures  A single line with a single integer, t, where 1 <= t <= 8, indicating the number of treasures. Number of Hunters  A single line with a single integer, h, where 1 <= h <= 6, indicating the number of treasure hunters. Treasure Value List  A series of h lines, one for each hunter in sequence (line 1 for hunter 1, line 2 for hunter 2, etc.). Each line contains a spaceseparated list of estimated treasure values for that hunter. The first estimate on each line is for treasure 1, the second is for treasure 2, etc., and an estimate for each treasure will appear for every hunter. Each estimate will be a positive integer strictly less than 10000. End line  A single line, "END" Output For each input data set, there will be exactly one output set, and there will be exactly one blank line separating output sets. Each output set consists of multiple lines, where each line represents a hunter (listed in the same order as the corresponding input data set). Each line contains a list of the treasures given to that hunter followed by the total perceived cash value (by that hunter), of all the treasures they receive. Treasures will be listed in ascending order by treasure number, and all values on each line will be spaceseparated. Treasures will be divided among the hunters in the fairest way possible. The "fairest" way to divide the treasure is defined to be the distribution with the minimum difference between the highest perceived total value and the lowest perceived total value of treasures received by any hunter. In other words, find the distribution that minimizes the difference between the hunter that gets the "most" and the hunter that gets the "least." There will not be multiple "fair" distributions. Sample Input START 5 3 42 500 350 700 100 250 200 500 1000 75 150 400 800 800 150 END START 5 3 42 500 350 200 100 250 200 500 1000 75 150 400 800 800 150 END START 5 3 500 500 350 200 100 250 200 500 1000 75 150 400 800 800 150 END Sample Output 4 700 3 5 575 1 2 550 1 4 5 342 3 500 2 400 1 2 1000 4 1000 3 5 950
 Treasure Hunt
 Description Archeologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of KeyOps. Using stateoftheart technology they are able to determine that the lower floor of the pyramid is constructed from a series of straightline walls, which intersect to form numerous enclosed chambers. Currently, no doors exist to allow access to any chamber. This stateoftheart technology has also pinpointed the location of the treasure room. What these dedicated (and greedy) archeologists want to do is blast doors through the walls to get to the treasure room. However, to minimize the damage to the artwork in the intervening chambers (and stay under their government grant for dynamite) they want to blast through the minimum number of doors. For structural integrity purposes, doors should only be blasted at the midpoint of the wall of the room being entered. You are to write a program which determines this minimum number of doors. An example is shown below: ![](http://poj.org/images/1066/t1.jpg) Input The input will consist of one case. The first line will be an integer n (0 <= n <= 30) specifying number of interior walls, followed by n lines containing integer endpoints of each wall x1 y1 x2 y2 . The 4 enclosing walls of the pyramid have fixed endpoints at (0,0); (0,100); (100,100) and (100,0) and are not included in the list of walls. The interior walls always span from one exterior wall to another exterior wall and are arranged such that no more than two walls intersect at any point. You may assume that no two given walls coincide. After the listing of the interior walls there will be one final line containing the floating point coordinates of the treasure in the treasure room (guaranteed not to lie on a wall). Output Print a single line listing the minimum number of doors which need to be created, in the format shown below. Sample Input 7 20 0 37 100 40 0 76 100 85 0 0 75 100 90 0 90 0 71 100 61 0 14 100 38 100 47 47 100 54.5 55.4 Sample Output Number of doors = 2
 财宝分配的一个算法，Treasure Division
 Problem Description Ant Tony and Monkey Luffy have discovered a big treasure.It turns out to be a box of gold coins.There are N gold coins in the box.However,the gold coins are not all the same.Every gold coin has a value Vi.Now they wants to divide this big treasure into two halves.The number of gold coin differ in two half must be no more than one.Tony and Luffy wants to know the fairest division,ie,the division which minimize the difference between each parts. Input Input contains multiple cases.Test cases are separated by several blank lines. Each test case starts with a integer N(1<=N<=30) ,indicating that there are N gold coins int the treasure box.Followed by one line contain N integer,the ith integer vi (1<=vi<=2^30),representing the value of coin i. Output For each case,output the least difference that could be found in one fairest division. Sample Input 3 2 2 4 4 1 2 3 6 Sample Output 0 2
 Treasure of the Chimp Island 程序步骤地实现
 Problem Description Bob Bennett, the young adventurer, has found the map to the treasure of the Chimp Island, where the ghost zombie pirate LeChimp, the infamous evil pirate of the Caribbeans has hidden somewhere inside the Zimbu Memorial Monument (ZM2). ZM2 is made up of a number of corridors forming a maze. To protect the treasure, LeChimp has placed a number of stone blocks inside the corridors to block the way to the treasure. The map shows the hardness of each stone block which determines how long it takes to destroy the block. ZM2 has a number of gates on the boundary from which Bob can enter the corridors. Fortunately, there may be a pack of dynamites at some gates, so that if Bob enters from such a gate, he may take the pack with him. Each pack has a number of dynamites that can be used to destroy the stone blocks in a much shorter time. Once entered, Bob cannot exit ZM2 and enter again, nor can he walk on the area of other gates (so, he cannot pick more than one pack of dynamites). The hardness of the stone blocks is an integer between 1 and 9, showing the number of days required to destroy the block. We neglect the time required to travel inside the corridors. Using a dynamite, Bob can destroy a block almost immediately, so we can ignore the time required for it too. The problem is to find the minimum time at which Bob can reach the treasure. He may choose any gate he wants to enter ZM2. Input The input consists of multiple test cases. Each test case contains the map of ZM2 viewed from the above. The map is a rectangular matrix of characters. Bob can move in four directions up, down, left, and right, but cannot move diagonally. He cannot enter a location shown by asterisk characters (*), even using all his dynamites! The character ($) shows the location of the treasure. A digit character (between 1 and 9) shows a stone block of hardness equal to the value of the digit. A hash sign (#) which can appear only on the boundary of the map indicates a gate without a dynamite pack. An uppercase letter on the boundary shows a gate with a pack of dynamites. The letter A shows there is one dynamite in the pack, B shows there are two dynamite in the pack and so on. All other characters on the boundary of the map are asterisks. Corridors are indicated by dots (.). There is a blank line after each test case. The width and the height of the map are at least 3 and at most 100 characters. The last line of the input contains two dash characters (). Output For each test case, write a single line containing a number showing the minimum number of days it takes Bob to reach the treasure, if possible. If the treasure is unreachable, write IMPOSSIBLE. Sample Input *****#********* *.1....4..$...* *..***..2.....* *..2..*****..2* *..3..******37A *****9..56....* *.....******..* ***CA********** ***** *$3** *.2** ***#*  Sample Output 1 IMPOSSIBLE
 C语言，Treasure of the Chimp Island
 Problem Description Bob Bennett, the young adventurer, has found the map to the treasure of the Chimp Island, where the ghost zombie pirate LeChimp, the infamous evil pirate of the Caribbeans has hidden somewhere inside the Zimbu Memorial Monument (ZM2). ZM2 is made up of a number of corridors forming a maze. To protect the treasure, LeChimp has placed a number of stone blocks inside the corridors to block the way to the treasure. The map shows the hardness of each stone block which determines how long it takes to destroy the block. ZM2 has a number of gates on the boundary from which Bob can enter the corridors. Fortunately, there may be a pack of dynamites at some gates, so that if Bob enters from such a gate, he may take the pack with him. Each pack has a number of dynamites that can be used to destroy the stone blocks in a much shorter time. Once entered, Bob cannot exit ZM2 and enter again, nor can he walk on the area of other gates (so, he cannot pick more than one pack of dynamites). The hardness of the stone blocks is an integer between 1 and 9, showing the number of days required to destroy the block. We neglect the time required to travel inside the corridors. Using a dynamite, Bob can destroy a block almost immediately, so we can ignore the time required for it too. The problem is to find the minimum time at which Bob can reach the treasure. He may choose any gate he wants to enter ZM2. Input The input consists of multiple test cases. Each test case contains the map of ZM2 viewed from the above. The map is a rectangular matrix of characters. Bob can move in four directions up, down, left, and right, but cannot move diagonally. He cannot enter a location shown by asterisk characters (*), even using all his dynamites! The character ($) shows the location of the treasure. A digit character (between 1 and 9) shows a stone block of hardness equal to the value of the digit. A hash sign (#) which can appear only on the boundary of the map indicates a gate without a dynamite pack. An uppercase letter on the boundary shows a gate with a pack of dynamites. The letter A shows there is one dynamite in the pack, B shows there are two dynamite in the pack and so on. All other characters on the boundary of the map are asterisks. Corridors are indicated by dots (.). There is a blank line after each test case. The width and the height of the map are at least 3 and at most 100 characters. The last line of the input contains two dash characters (). Output For each test case, write a single line containing a number showing the minimum number of days it takes Bob to reach the treasure, if possible. If the treasure is unreachable, write IMPOSSIBLE. Sample Input *****#********* *.1....4..$...* *..***..2.....* *..2..*****..2* *..3..******37A *****9..56....* *.....******..* ***CA********** ***** *$3** *.2** ***#*  Sample Output 1 IMPOSSIBLE
 Treasure Map
 Description You have come into possession of a pirate map that gives a series of steps to get from your landing place on a desert isle to the spot marked X where the treasure is located. Each step consists of a compass heading and a number of paces. After spending most of your savings chartering a boat, you arrive at the island and, with the help of your portable GPS receiver, duly execute the instructions on the map. Alas, no treasure! On your return home you are astonished to learn that the pirates had no knowledge of GPS and used a magnetic compass to create the map. The pirates were unaware that their compass pointed to magnetic north rather than true north. The relative angle between magnetic north and true north varies depending where you are on the planet, but you are able to determine that on this particular desert isle, magnetic north is d degrees from true north. How close were you to the spot marked X at any moment while following the map? Input There are several test cases. Each test case begins with n <= 1000, the number of steps in the map. n lines follow; each consists of one of the 32 named compass points shown at right followed by a number of paces. The last line is a number giving the angle between magnetic north and true north, in degrees. A positive number indicates that magnetic north is to the east of true north; a negative indicates that it is to the west. The magnitude of this angle will not exceed 90 degrees. A line containing 0 follows the input for the last case. Note:We use combinations of the letters N,E,S,W,b to abbreviate the names of the compass points. For example, NEbE stands for northeast by east. The 32 points are equally spaced about the compass. Clockwise, they are: N NbE NNE NEbN NE NEbE ENE EbN E EbS ESE SEbE SE SEbS SSE SbE S SbW SSW SWbS SW SWbW WSW WbS W WbN WNW NWbW NW NWbN NNW NbW. Output For each test case, output a single number, rounded to two decimal places, giving the least distance (in paces) that separated you from the treasure at any point while you were following the map. Sample Input 2 NbE 10 EbS 10 90.00 2 NbE 10 EbS 10 90.00 0 Sample Output 14.14 10.00
 Get The Treasure用代码的实现
 Problem Description One day, a team of archaeologists found a figure and some ancient charactors at a relique. The figure was made up of n points distributing on a circle symmetrically. After investigating the charactors, they got to know that a treasure was hid beneath the figure. In order to open the door to the treasure, they must redraw all the lines between any two points in the figure with some colors. If the figure was right, the door would open. Now they want to know how many times they have to try at most to open the door, and they ask you for help. Input Each test case contains an integer n and a string S in a line. n is the number of points in the figure and S is a string made up of distinct capital letters, each indicating a color that can be used to redraw the figure. 3 <= n <= 50. Output Each case outputs the maximum times they may try in one line. Note that two figures are considered the same if one can be obtained by having rotation and mirroring on the other one. Sample Input 3 BW 3 RGB 4 RG Sample Output 4 10 19
 The Treasure
 We have arrived at the age of the Internet. Many software applications have transformed from standalone to online applications. Computer games are following this trend as well. Online games are becoming more and more popular, not only because they are more intelligent, but also because they can bring great profits. "The computer game industry is developing rapidly in China. Online game revenues amounted to 1.3 billion Yuan last year and are expected to reach 6.7 billion Yuan by 2007." reported by China Daily in 2004. However, good games originate from good programmers. We take for example that there is a RPG (Role Playing Game) and your boss asks you to implement some tasks. For simplicity's sake, we assume there are two kinds of roles in this game: one is player and the other is monster. You should help the player to achieve the goal: reach the place where treasure is positioned as early as possible and get the treasure. The map of the game is a matrix of N * M identical cells. Some cells are passable blocks, and others are nonpassable rocks. At any time, there is at most one role occupying a block. At the beginning, the time is set to 0, and the player is at a certain block. He then moves towards the treasure. At each turn, we have some rules: The player can stay in the same block during the next onesecond time duration, or he can walk or run towards the east, south, west, north, northeast, northwest, southeast, and southwest. With walking, the player can arrive at the corresponding passable blocks around him (See Fig.1). Each move takes 1 second. With running, the player can arrive at the corresponding passable blocks 2 cells away from him (See Fig.2). Each run takes 1 second. As demonstrated in Fig.3, if a neighbor cell is not passable, the player cannot run in that direction. For example, if cell 2 is a rock, running from 1 to 3 is impossible. The monsters are classified into aggressive and nonaggressive. If a monster occupies a cell, the player cannot move into that cell or run through that cell. In addition, the player cannot move into the cells surrounding an aggressive monster, because it will attack the player near it. For example, in Fig.4, if there is an aggressive monster in 5, then the cell 1, 2, 3, 4, 6, 7, 8 and 9 are in its attacking region, so the player cannot stay in or pass through these cells. Monsters change their positions each turn. Each monster appears by its position sequence iteratively. That's to say, given the position sequence of monster i: (x1, y1), (x2, y2), ..., (xs, ys), its initial position is (x1, y1) at time 0, then it appears in (x2, y2) at time 1, and so on. When monster i arrives at (xs, ys) at time s1, it will arrive in (x1, y1) at time s, and start to repeat. At the start of each turn, all the monsters change their positions first (the way of changing is given above). If a monster appears in the player's cell, or if an aggressive monster appears near the player to put him in its attacking region, the player will die, and the goal cannot be achieved. After all the monsters change their positions, the player makes a move or stays in the same cell. In his move, the moving path should not be occupied by any rocks or monsters or in the attacking region of any aggressive monsters. When counting the total time, we can neglect the time between monsters' position change and the player's move. Given the map of the game, the player's starting position, the treasure position and all the monsters' positions in every second, your task is to write a program to find the minimum time that the player gets the treasure. Input The input consists of several test cases. The first line of each case contains two integers N and M (1 <= N, M <= 100), where N is the height of the map and M is the width of the map. This is followed by N lines each containing M characters representing the map. A '#' represents a rock, a '.' is a free block, 'p' is the starting position of the player, 't' is the position of the treasure, 'n' is the initial position of a nonaggressive monster, and an 'a' stands for the initial position of an aggressive monster. The cell (i, j) is the jth cell on the ith row counting from left to right. The rows are counted from 1 to N starting from the first line of the matrix. We can number all the monsters as 1, 2, 3�� according to their initial position, sorting first by row, then by column. The (n+2)th line contains an integer p (0 <= p <= 100), which is the total number of monsters (i.e. the total number of 'n's and 'a's in the matrix). It is followed by p lines each specifying a monster's position sequence in the following format: the ith (1 <= i <= p) line corresponds to monster i, which begins with an integer s (1 <= s <= 100), meaning the length of position sequence. Then s pairs of integers x1, y1, x2, y2, ��, xs, ys are followed, separated by blanks. Each pair is a free block in the map, (i.e. a monster never goes to a rock cell). It is assured that none of the aggressive monsters' initial position is around the player. Two consecutive cases are separated by a blank line. The input is terminated by a line containing a pair of zeros. Output For each test case, output the minimum total time required for the player to get the treasure, in seconds. If it's not possible to get the treasure, or the minimum required time is greater than 100 seconds, please print a line just containing the string "impossible". Two consecutive cases should be separated by a blank line. Sample Input 7 8 #.#####. #.t#..p. #..#.... ..#a.#.# #...##.n .#...... ........ 2 2 4 4 5 4 3 5 8 6 8 5 7 3 3 p#. ##. t.. 0 2 2 #t p# 0 0 0 Sample Output 8 impossible 1
 爬虫福利二 之 妹子图网MM批量下载
 爬虫福利一：27报网MM批量下载 点击 看了本文，相信大家对爬虫一定会产生强烈的兴趣，激励自己去学习爬虫，在这里提前祝：大家学有所成！ 目标网站：妹子图网 环境：Python3.x 相关第三方模块：requests、beautifulsoup4 Re：各位在测试时只需要将代码里的变量path 指定为你当前系统要保存的路径，使用 python xxx.py 或IDE运行即可。 ...
 字节跳动视频编解码面经
 三四月份投了字节跳动的实习（图形图像岗位），然后hr打电话过来问了一下会不会opengl，c++，shador，当时只会一点c++，其他两个都不会，也就直接被拒了。 七月初内推了字节跳动的提前批，因为内推没有具体的岗位，hr又打电话问要不要考虑一下图形图像岗，我说实习投过这个岗位不合适，不会opengl和shador，然后hr就说秋招更看重基础。我当时想着能进去就不错了，管他哪个岗呢，就同意了面试...
 Java学习的正确打开方式
 在博主认为，对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结，前三者博主将淋漓尽致地挥毫于这篇博客文章中，至于总结在于个人，实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍，博客次之，这又是一个层次了，这里暂时不提后面再谈。博主将为各位入门java保驾护航，各位只管冲鸭！！！上天是公平的，只要不辜负时间，时间自然不会辜负你。 何谓学习？博主所理解的学习，它是一个过程，是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
 程序员必须掌握的核心算法有哪些？
 由于我之前一直强调数据结构以及算法学习的重要性，所以就有一些读者经常问我，数据结构与算法应该要学习到哪个程度呢？，说实话，这个问题我不知道要怎么回答你，主要取决于你想学习到哪些程度，不过针对这个问题，我稍微总结一下我学过的算法知识点，以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的，并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构，当然，我也会整理一些看过...
 linux系列之常用运维命令整理笔录
 本博客记录工作中需要的linux运维命令，大学时候开始接触linux，会一些基本操作，可是都没有整理起来，加上是做开发，不做运维，有些命令忘记了，所以现在整理成博客，当然vi，文件操作等就不介绍了，慢慢积累一些其它拓展的命令，博客不定时更新 free m 其中：m表示兆，也可以用g，注意都要小写 Men：表示物理内存统计 total：表示物理内存总数(total=used+free) use...
 Python 基础（一）：入门必备知识
 Python 入门必备知识，你都掌握了吗？
 兼职程序员一般可以从什么平台接私活？
 这个问题我进行了系统性的总结，以下将进行言简意赅的说明和渠道提供，希望对各位小猿/小媛们有帮助~ 根据我们的经验，程序员兼职主要分为三种：兼职职位众包、项目整包和自由职业者驻场。 所谓的兼职职位众包，指的是需求方这边有自有工程师配合，只需要某个职位的工程师开发某个模块的项目。比如开发一个 app，后端接口有人开发，但是缺少 iOS 前端开发工程师，那么他们就会发布一个职位招聘前端，来配合公司一...
 程序员接私活怎样防止做完了不给钱？
 首先跟大家说明一点，我们做 IT 类的外包开发，是非标品开发，所以很有可能在开发过程中会有这样那样的需求修改，而这种需求修改很容易造成扯皮，进而影响到费用支付，甚至出现做完了项目收不到钱的情况。 那么，怎么保证自己的薪酬安全呢？ 我们在开工前，一定要做好一些证据方面的准备（也就是“讨薪”的理论依据），这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
 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）杨辉三角
 写在前面： 我是 扬帆向海，这个昵称来源于我的名字以及女朋友的名字。我热爱技术、热爱开源、热爱编程。技术是开源的、知识是共享的。 这博客是对自己学习的一点点总结及记录，如果您对 Java、算法 感兴趣，可以关注我的动态，我们一起学习。 用知识改变命运，让我们的家人过上更好的生活。 目录一、杨辉三角的介绍二、杨辉三角的算法思想三、代码实现1.第一种写法2.第二种写法 一、杨辉三角的介绍 百度
 腾讯算法面试题：64匹马8个跑道需要多少轮才能选出最快的四匹？
 昨天，有网友私信我，说去阿里面试，彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static？他被难住了，因为他从来都没有考虑过这个问题。无独有偶，今天笔者又发现有网友吐槽了一道腾讯的面试题，我们一起来看看。 腾讯算法面试题：64匹马8个跑道需要多少轮才能选出最快的四匹？ 在互联网职场论坛，一名程序员发帖求助到。二面腾讯，其中一个算法题：64匹...
 面试官：你连RESTful都不知道我怎么敢要你？
 干货，2019 RESTful最贱实践
 为啥国人偏爱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...
 致 Python 初学者
 欢迎来到“Python进阶”专栏！来到这里的每一位同学，应该大致上学习了很多 Python 的基础知识，正在努力成长的过程中。在此期间，一定遇到了很多的困惑，对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言，从2009年开始单一使用 python 应对所有的开发工作，直至今天。回顾自己的学习过程，也曾经遇到过无数的困难，也曾经迷茫过、困惑过。开办这个专栏，正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
 “狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作
 一、垃圾文字生成器介绍 最近在浏览GitHub的时候，发现了这样一个骨骼清奇的雷人项目，而且热度还特别高。 项目中文名：狗屁不通文章生成器 项目英文名：BullshitGenerator 根据作者的介绍，他是偶尔需要一些中文文字用于GUI开发时测试文本渲染，因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理，所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的： 你发现，
 程序员：我终于知道post和get的区别
 IT界知名的程序员曾说：对于那些月薪三万以下，自称IT工程师的码农们，其实我们从来没有把他们归为我们IT工程师的队伍。他们虽然总是以IT工程师自居，但只是他们一厢情愿罢了。 此话一出，不知激起了多少(码农)程序员的愤怒，却又无可奈何，于是码农问程序员。 码农：你知道get和post请求到底有什么区别？ 程序员：你看这篇就知道了。 码农：你月薪三万了？ 程序员：嗯。 码农：你是怎么做到的? 程序员：
 《程序人生》系列这个程序员只用了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
 8年经验面试官详解 Java 面试秘诀
 作者  胡书敏 责编  刘静 出品  CSDN（ID：CSDNnews） 本人目前在一家知名外企担任架构师，而且最近八年来，在多家外企和互联网公司担任Java技术面试官，前后累计面试了有两三百位候选人。在本文里，就将结合本人的面试经验，针对Java初学者、Java初级开发和Java开发，给出若干准备简历和准备面试的建议。 Java程序员准备和投递简历的实
 面试官如何考察你的思维方式？
 1.两种思维方式在求职面试中，经常会考察这种问题：北京有多少量特斯拉汽车？ 某胡同口的煎饼摊一年能卖出多少个煎饼？ 深圳有多少个产品经理？ 一辆公交车里能装下多少个乒乓球？ 一
 碎片化的时代，如何学习
 今天周末，和大家聊聊学习这件事情。 在如今这个社会，我们的时间被各类 APP 撕的粉碎。 刷知乎、刷微博、刷朋友圈； 看论坛、看博客、看公号； 等等形形色色的信息和知识获取方式一个都不错过。 貌似学了很多，但是却感觉没什么用。 要解决上面这些问题，首先要分清楚一点，什么是信息，什么是知识。 那什么是信息呢？ 你一切听到的、看到的，都是信息，比如微博上的明星出轨、微信中的表情大战、抖音上的...
 so easy！ 10行代码写个"狗屁不通"文章生成器
 前几天，GitHub 有个开源项目特别火，只要输入标题就可以生成一篇长长的文章。 背后实现代码一定很复杂吧，里面一定有很多高深莫测的机器学习等复杂算法 不过，当我看了源代码之后 这程序不到50行 尽管我有多年的Python经验，但我竟然一时也没有看懂 当然啦，原作者也说了，这个代码也是在无聊中诞生的，平时撸码是不写中文变量名的, 中文...
 知乎高赞：中国有什么拿得出手的开源软件产品？(整理自本人原创回答)
 知乎高赞：中国有什么拿得出手的开源软件产品？ 在知乎上，有个问题问“中国有什么拿得出手的开源软件产品（在 GitHub 等社区受欢迎度较好的）？” 事实上，还不少呢~ 本人于2019.7.6进行了较为全面的回答，对这些受欢迎的 Github 开源项目分类整理如下： 分布式计算、云平台相关工具类 1.SkyWalking，作者吴晟、刘浩杨 等等 仓库地址: apache/skywalking 更...
 基础拾遗:除了&和&&的区别,你还要知道位运算的这5个运算符
 &和&&都可作逻辑与的运算符，表示逻辑与（and），&是位运算符，你还需要知道这5个位运算符，基础很重要，云运算其实很骚！
 MySQL数据库总结
 一、数据库简介 数据库(Database，DB)是按照数据结构来组织，存储和管理数据的仓库。 典型特征：数据的结构化、数据间的共享、减少数据的冗余度，数据的独立性。 关系型数据库：使用关系模型把数据组织到数据表(table)中。现实世界可以用数据来描述。 主流的关系型数据库产品：Oracle(Oracle)、DB2(IBM)、SQL Server(MS)、MySQL(Oracle)。 数据表：数...
 20行Python代码爬取王者荣耀全英雄皮肤
 引言 王者荣耀大家都玩过吧，没玩过的也应该听说过，作为时下最火的手机MOBA游戏，咳咳，好像跑题了。我们今天的重点是爬取王者荣耀所有英雄的所有皮肤，而且仅仅使用20行Python代码即可完成。 准备工作 爬取皮肤本身并不难，难点在于分析，我们首先得得到皮肤图片的url地址，话不多说，我们马上来到王者荣耀的官网： 我们点击英雄资料，然后随意地选择一位英雄，接着F12打开调试台，找到英雄原皮肤的图片...