 Lode Runner

Problem Description
Lode Runner is a famous game, I think you played in your childhood.Ok, now, I simple the problem. In the game, it has N horizontal roads, the ladders always stay at right side vertically, and the ladders are extending towards up and down with unlimited length. If ladder near or cross a road, little WisKey will walk on the road by climbed the ladder. Two roads were covered by each other in the Xaxis; it will be considered can be passing through. Each road has an integer W means the dangerous level.
Little WisKey must start at No.1 road, and he can’t go back, he always go ahead. WisKey want to go some roads, so he needs to know how minimum sum of dangerous will happen. You can finish the game, yes?
Input
The first integer C represents the number of cases, And C cases followed.Each test case contains a single integer N roads (1<=N<= 2000) and M destinations (1<=M<=500). The next N line contains three integers Si, Ei, Wi, meaning the road build from Si to Ei, and the Wi dangerous level (0 <= Si <= Ei <= 1000, 1 <= Wi <= 1000). And the roads sorted by Ei increasing yet. The last M line contains integers mean little WisKey’s destinations.
Output
For each questions, output the minimum sum of dangerous. If can’t reach the goal, please print 1.
Sample Input
3
10 4
1 4 7
5 6 3
3 7 5
2 9 8
10 13 8
12 14 11
11 15 13
16 18 5
17 19 6
8 20 9
1
2
3
10
5 5
1 4 5
3 6 10
5 8 20
2 9 1
7 10 2
1
2
3
4
5
4 4
1 5 1
2 7 20
2 7 3
7 9 4
1
2
3
4Sample Output
7
1
12
24
5
15
35
6
8
1
21
4
8
COURSES _course
20171026Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is possible to form a committee of exactly P students that satisfies simultaneously the conditions: every student in the committee represents a different course (a student can represent a course if he/she visits that course) each course has a representative in the committee Input Your program should read sets of data from the std input. The first line of the input contains the number of the data sets. Each data set is presented in the following format: P N Count1 Student1 1 Student1 2 ... Student1 Count1 Count2 Student2 1 Student2 2 ... Student2 Count2 ... CountP StudentP 1 StudentP 2 ... StudentP CountP The first line in each data set contains two positive integers separated by one blank: P (1 <= P <= 100)  the number of courses and N (1 <= N <= 300)  the number of students. The next P lines describe in sequence of the courses �from course 1 to course P, each line describing a course. The description of course i is a line that starts with an integer Count i (0 <= Count i <= N) representing the number of students visiting course i. Next, after a blank, you抣l find the Count i students, visiting the course, each two consecutive separated by one blank. Students are numbered with the positive integers from 1 to N. There are no blank lines between consecutive sets of data. Input data are correct. Output The result of the program is on the standard output. For each input data set the program prints on a single line "YES" if it is possible to form a committee and "NO" otherwise. There should not be any leading blanks at the start of the line. Sample Input 2 3 3 3 1 2 3 2 1 2 1 1 3 3 2 1 3 2 1 3 1 1 Sample Output YES NO
AC Me _course
20170127问题描述 : Ignatius is doing his homework now. The teacher gives him some articles and asks him to tell how many times each letter appears. It’s really easy, isn’t it? So come on and AC ME. 输入: Each article consists of just one line, and all the letters are in lowercase. You just have to count the number of each letter, so do not pay attention to other characters. The length of article is at most 100000. Process to the end of file. Note: the problem has multicases, and you may use "while(gets(buf)){…}" to process to the end of file. 输出: For each article, you have to tell how many times each letter appears. The output format is like "X:N". Output a blank line after each test case. More details in sample output. 样例输入: hello, this is my first acm contest! work hard for hdu acm. 样例输出: a:1 b:0 c:2 d:0 e:2 f:1 g:0 h:2 i:3 j:0 k:0 l:2 m:2 n:1 o:2 p:0 q:0 r:1 s:4 t:4 u:0 v:0 w:0 x:0 y:1 z:0 a:2 b:0 c:1 d:2 e:0 f:1 g:0 h:2 i:0 j:0 k:1 l:0 m:1 n:0 o:2 p:0 q:0 r:3 s:0 t:0 u:1 v:0 w:1 x:0 y:0 z:0
Scheduling Lectures _course
20171017Description You are teaching a course and must cover n (1 <= n <= 1000) topics. The length of each lecture is L (1 <= L <= 500) minutes. The topics require t1, t2, ..., tn (1 <= ti <= L) minutes each. For each topic, you must decide in which lecture it should be covered. There are two scheduling restrictions: 1. Each topic must be covered in a single lecture. It cannot be divided into two lectures. This reduces discontinuity between lectures. 2. Topic i must be covered before topic i + 1 for all 1 <= i < n. Otherwise, students may not have the prerequisites to understand topic i + 1. With the above restrictions, it is sometimes necessary to have free time at the end of a lecture. If the amount of free time is at most 10 minutes, the students will be happy to leave early. However, if the amount of free time is more, they would feel that their tuition fees are wasted. Therefore, we will model the dissatisfaction index (DI) of a lecture by the formula: 0 if t=0 DI=C if 1 <= t <= 10 (t10)^2 otherwise where C is a positive integer, and t is the amount of free time at the end of a lecture. The total dissatisfaction index is the sum of the DI for each lecture. For this problem, you must find the minimum number of lectures that is needed to satisfy the above constraints. If there are multiple lecture schedules with the minimum number of lectures, also minimize the total dissatisfaction index. Input The input consists of a number of cases. The first line of each case contains the integer n, or 0 if there are no more cases. The next line contains the integers L and C. These are followed by n integers t1, t2, ..., tn. Output For each case, print the case number, the minimum number of lectures used, and the total dissatisfaction index for the corresponding lecture schedule on three separate lines. Output a blank line between cases. Sample Input 6 30 15 10 10 10 10 10 10 10 120 10 80 80 10 50 30 20 40 30 120 100 0 Sample Output Case 1: Minimum number of lectures: 2 Total dissatisfaction index: 0 Case 2: Minimum number of lectures: 6 Total dissatisfaction index: 2700
Partition a Matrix _course
20171017Description Given an M * N matrix consisted of nonnegative elements, you may partition it into three parts with two straight line segments. The line segments cannot go through any element of the matrix and they must be parallel to the row or the column of the matrix, but they need not to be parallel to each other. Each of the three parts is a nonempty matrix, which means it contains at least one element. We define the value of a matrix as the sum of all elements in it. We denote the values of the three remaining matrices as X, Y, Z, and the balance degree as X  Y + Y  Z + Z  X, where . means the absolute value. Among all ways of partition, there is one, which has the least balance degree. Your task is to decide what the least balance degree is. Input The input will consist of several test cases. For each test case, two integers M and N are given in the first line, indicating the number of rows and columns of the matrix; each of the following M lines contains N integers, indicating the matrix. The input is terminated by a single line with two zeros. You may assume that 2 <= M, N <= 500 and all elements of the matrix are integers in the range [0, 65535]. There may be some blank lines between test cases. Output For each matrix of the input, print a line containing the least balance degree. Sample Input 3 3 9 8 7 6 5 4 3 2 1 0 0 Sample Output 10
Housing Complexes _course
20171017Description The Ministry of housing is planning a huge construction project of several housing complexes. Each complex includes several apartments to be sold to government employees at reasonable prices. The ministry has located several big m*n pieces of land that can potentially be used for such construction project; one complex in each land. The lands are all rectangular, each with m*n number of 1*1 square blocks. All housing complexes are h*w rectangles covering exactly h*w blocks of each containing land. The problem is that there are originally some old buildings, each covering exactly one block of a land, making it impossible to locate enough free space for all the complexes in order to start the project. Therefore, the ministry has to buy some of these buildings, and demolish them to free the needed space. The old buildings belong to certain number of people. These people are angry of the possibility that their building may be bought and demolished, especially because the government usually pays much less for their buildings compared to the open market prices. In response to the protests, the ministry announces a "fair" decision that if it buys some buildings in one land, it will only choose those that belong only to one owner, and will buy all of them at reasonable price. And, it promises not to buy buildings belonging to the same owner in other lands. Note that with this constraint, there may be some lands in which building a complex is impossible. Trying to keep its promises, the ministry has asked you to write a program to see how many housing complexes can be constructed at most with these conditions. Input The first line of the input file contains a single integer t (1 <= t <= 10), the number of test cases, followed by the input data for each test case. The first line of each test case contains five integers k (1 <= k <= 30), the number of lands, m and n (1 <= m, n <= 50), the number of rows and columns in each land respectively, and h and w (1 <= h, w <= 50), the number of rows and columns a complex occupies. After the first line, there are k*m lines in the input, representing k lands, each by an m*n matrix. Each line contains a string of length n with no leading or trailing spaces. Each character in the strings represents a block in the land and may be an upper case alphabetic character 'A'..'Z', indicating the owner of the block, or the character '0' indicating the block is free. Output There should be one line per test case containing the maximum number of housing complexes that can be constructed for that test case. Sample Input 2 3 4 3 3 2 A0B 000 0A0 00B AA0 00B 0B0 000 A0A 000 B00 B00 3 4 3 3 2 A0B 000 0A0 00B AA0 00B 0B0 000 A0A 000 0B0 B00 Sample Output 3 2
最小生成树问题，c代码_course
20130624题目描述 Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms. Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm. The distance between any two farms will not exceed 100,000. 输入 The input includes several cases. For each case, the first line contains the number of farms, N (3 <= N <= 500). The following lines contain the N x N conectivity matrix, where each element shows the distance from one farm to another. Logically, they are N lines of N spaceseparated integers. Of course, the diagonal will be 0, since the distance from farm i to itself is not interesting for this problem 输出 For each case, output a single integer length that is the sum of the minimum length of fiber required to connect the entire set of farms. 样例输入 6 0 6 1 5 100 100 6 0 5 100 3 100 1 5 0 5 6 4 5 100 5 0 100 2 100 3 6 100 0 6 100 100 4 2 6 0 样例输出 15 提示 题意简述：在n个城市之间铺设光缆，铺设光缆费用很高且各个城市之间铺设光缆的费用不同。设计目标是使这n个城市之间的任意2个城市都可以直接或间接通信，并且要使铺设光缆的费用最低。 解题思路：这样的问题是一个求最小生成树的问题。解决这个问题的方法就是在由n个城市结点和n(n1)/2条费用不同的边构成的无向连通图中找出最小生成树。首选Prim算法，也可以用Kruskal算法。 样例的数据来源于教材图7.16，用邻接矩阵表示。 生词： optical fiber 光缆 N x N conectivity matrix N x N的邻接矩阵 spaceseparated integers 空格隔开的整数 the diagonal 对角线
Street Directions _course
20171016Description According to the Automobile Collision Monitor (ACM), most fatal traffic accidents occur on twoway streets. In order to reduce the number of fatalities caused by traffic accidents, the mayor wants to convert as many streets as possible into oneway streets. You have been hired to perform this conversion, so that from each intersection, it is possible for a motorist to drive to all the other intersections following some route. You will be given a list of streets (all twoway) of the city. Each street connects two intersections, and does not go through an intersection. At most four streets meet at each intersection, and there is at most one street connecting any pair of intersections. It is possible for an intersection to be the end point of only one street. You may assume that it is possible for a motorist to drive from each destination to any other destination when every street is a twoway street. Input The input consists of a number of cases. The first line of each case contains two integers n and m. The number of intersections is n (2 <= n <= 1000), and the number of streets is m. The next m lines contain the intersections incident to each of the m streets. The intersections are numbered from 1 to n, and each street is listed once. If the pair i j is present, j i will not be present. End of input is indicated by n = m = 0. Output For each case, print the case number (starting from 1) followed by a blank line. Next, print on separate lines each street as the pair i j to indicate that the street has been assigned the direction going from intersection i to intersection j. For a street that cannot be converted into a oneway street, print both i j and j i on two different lines. The list of streets can be printed in any order. Terminate each case with a line containing a single `#' character. Note: There may be many possible direction assignments satisfying the requirements. Any such assignment is acceptable. Sample Input 7 10 1 2 1 3 2 4 3 4 4 5 4 6 5 7 6 7 2 5 3 6 7 9 1 2 1 3 1 4 2 4 3 4 4 5 5 6 5 7 7 6 0 0 Sample Output 1 1 2 2 4 3 1 3 6 4 3 5 2 5 4 6 4 6 7 7 5 # 2 1 2 2 4 3 1 4 1 4 3 4 5 5 4 5 6 6 7 7 5 #
Hall of Fountains _course
20171016Description The Museum of Modern Art has a really exciting exhibition: a kind of a longish hall composed of a sequence of quadraticshaped rooms. Each room is equipped with a water fountain. Each fountain is characterized by a number p and acts independent of the others. It will be turned on for exactly p seconds, then it will be turned off for exactly p seconds, then on again, then off again, and so on for good. However, different fountains may have different values of p. And even if they share the same value, they still may perform not identically, for they might have been started at different times. You stand in front of the first room, and want to cross the hall to the other end. Each of your steps takes exactly 1 second. You are able to move one room forward (unless you already reached the other end), one room backward (unless you are at the beginning), or just stay at your current position. Calculate the shortest time to reach the other end, if it is possible at all. Since you do not want to get wet, you can only move into a room where the water fountain will be off during the second after your step. For example, suppose that the fountain in the next room behaves so, that it is on at times 0, 1, 2, then off at times 3, 4, 5, 6, then on at times 7, 8, 9, 10, then off again (which indicates p=4 with an offset of 7). Then, you can move at time 2 into the room, arriving there at time 3, when the fountain is off. But you cannot move at time 6 into the room, because at time 7 it will be on. Input The input contains several test cases. Each test case starts with the number of fountains n. Input is terminated by n=0. Otherwise, 1<=n<=100. Then follow n numbers pi denoting the time each fountain is on and off, where 0<=pi<=10. A value of 0 for pi indicates that fountain i is out of order (i.e. constantly off). Then follow n numbers qi denoting the offset of each fountain, where 0<=qi<2*pi, unless the fountain is out of order, in which case qi is meaningless. Otherwise it means that fountain i will be on at time qi, but off just one second before. Output For each test case output on a line a single number t denoting the shortest time needed to reach the end of the hall (i.e. to enter the place after the last room). Assume, that you are in front of the first room at time 0 (i.e. you can enter the first room at time 1, if the fountain is off at time 1). If it is impossible to go through the hall of fountains, print 0 instead. Sample Input 3 0 0 0 0 0 0 4 6 3 3 4 2 3 0 4 2 1 1 0 0 0 Sample Output 4 11 0
已知每个顶点的入度和出度，用最大流的方式求边_course
20141214比如已知出度是(2, 1, 1, 1)，入度是(1, 2, 1, 1). 如下是解法图解： ![解法图解](http://chuantu.biz/t/56/1418549200x954497606.gif) 根据英文解释和图解，它的做法是，先弄出起点X和终点Y，根据每个顶点的出度，得到X_A的容量是2，X_B、X_C、X_D的容量是1；然后从A、B、C、D引出边到其他顶点，因为顶点之间只可能有一条边，所以这些边的容量是1。假定最大流是边的个数，也就是出度或者入度的和，这里计算得到是5。 我的疑惑是：它怎么根据最大流得到中间那些红色边的呢？？ 附英文： Let's take this problem for instance: "You are given the in and out degrees of the vertices of a directed graph. Your task is to find the edges (assuming that no edge can appear more than once)." First, notice that we can perform this simple test at the beginning. We can compute the number M of edges by summing the outdegrees or the indegrees of the vertices. If these numbers are not equal, clearly there is no graph that could be built. This doesn't solve our problem, though. There are some greedy approaches that come to mind, but none of them work. We will combine the tricks discussed above to give a maxflow algorithm that solves this problem. First, build a network that has 2 (in/out) vertices for each initial vertex. Now draw an edge from every out vertex to every in vertex. Next, add a supersource and draw an edge from it to every outvertex. Add a supersink and draw an edge from every in vertex to it. We now need some capacities for this to be a flow network. It should be pretty obvious what the intent with this approach is, so we will assign the following capacities: for each edge drawn from the supersource we assign a capacity equal to the outdegree of the vertex it points to. As there may be only one arc from a vertex to another, we assign a 1 capacity to each of the edges that go from the outs to the ins. As you can guess, the capacities of the edges that enter the supersink will be equal to the indegrees of the vertices. If the maximum flow in this network equals M  the number of edges, we have a solution, and for each edge between the out and in vertices that has a flow along it (which is maximum 1, as the capacity is 1) we can draw an edge between corresponding vertices in our graph. Note that both xy and yx edges may appear in the solution. This is very similar to the maximum matching in a bipartite graph that we will discuss later. An example is given below where the outdegrees are (2, 1, 1, 1) and the indegrees (1, 2, 1, 1). 问题来源： http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=maxFlow2
急求大神帮忙啊！matlab中遇到的矩阵变量问题_course
20150921v=[ ];x=[ ];a=[ ]; f=[ ];g=[ ];b=[ ];w=[ ];u=[ ];gg0=[ ];可以在matlab2013中这样编辑动态的数组变量吗？为什么会出现以下错误呢 The size of the indicated variable or array appears to be changing with each loop iteration. Commonly, this message appears because an array is growing by assignment or concatenation. Growing an array by assignment or concatenation can be expensive. For large arrays, MATLAB must allocate a new block of memory and copy the older array contents to the new array as it makes each assignment. Programs that change a variable's size in this way can spend most of their run time in this inefficient activity. 翻译为：显示变量或数组的大小与每个循环迭代似乎正在改变。一般,这个消息似乎因为增加数组赋值或连接。增长数组赋值或连接可以是昂贵的。对于大型阵列,MATLAB必须分配一个新的块内存和年长的数组内容复制到新数组,因为它使每个任务。程序,以这种方式改变一个变量的大小可以花大部分运行时间在这种低效率的活动。
juicer在jsp上渲染失败，html成功_course
20161216<%@page language="java" contentType="text/html; charset=UTF8" pageEncoding="UTF8"%> <!DOCTYPE html PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta httpequiv="ContentType" content="text/html; charset=UTF8"> <title>this is juicer test</title> <script type="text/javascript" src="dist/js/juicer.js"></script> </head> <body> <script type="text/javascript"> var data={ list:[ {name:'guokai',show:true}, {name:'benben',show:false}, {name:'dier',show:true} ], blah:[ {num:1}, {num:2}, {num:3,inner:[ {'time':'15:00'}, {'time':'16:00'}, {'time':'17:00'}, {'time':'18:00'} ]}, {num:4} ] }; var tpl=[ '<ul>', '{@each list as it, k}', '<li>${it.name} (index: ${k})</li>', '{@/each}', '{# first level attribute must specify the "data." prefix}', '{@each blah as it}', '<li>', 'num: ${it.num} <br />', '{@if it.num==3}', '{@each it.inner as it2}', '${it2.time} <br />', '{@/each}', '{@/if}', '</li>', '{@/each}', '</ul>' ].join('\n'); var inc=function(n) { return n+1; }; var starttimestamp=new Date().getTime(); juicer.set('cache',true); juicer.set('errorhandling',false); juicer.set('strip',true); juicer.set('detection',false); for(var i=0;i<1000;i++) { juicer(tpl,data); } var endtimestamp=new Date().getTime(); var exhausttime=endtimestampstarttimestamp; document.write(juicer(tpl,data)); document.write('run time: '+exhausttime); console.log(juicer(tpl).render.toString()); console.log(exhausttime); </script> </body> </html> ![图片说明](https://imgask.csdn.net/upload/201612/16/1481872618_138290.jpg) ==================下面是成功的====================== <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF8"> <title></title> <script type="text/javascript" src="../src/juicer.js"></script> </head> <body> <script type="text/javascript"> var data={ list:[ {name:'guokai',show:true}, {name:'benben',show:false}, {name:'dier',show:true} ], blah:[ {num:1}, {num:2}, {num:3,inner:[ {'time':'15:00'}, {'time':'16:00'}, {'time':'17:00'}, {'time':'18:00'} ]}, {num:4} ] }; var tpl=[ '<ul>', '{@each list as it, k}', '<li>${it.name} (index: ${k})</li>', '{@/each}', '{# first level attribute must specify the "data." prefix}', '{@each blah as it}', '<li>', 'num: ${it.num} <br />', '{@if it.num==3}', '{@each it.inner as it2}', '${it2.time} <br />', '{@/each}', '{@/if}', '</li>', '{@/each}', '</ul>' ].join('\n'); var inc=function(n) { return n+1; }; var starttimestamp=new Date().getTime(); juicer.set('cache',true); juicer.set('errorhandling',false); juicer.set('strip',true); juicer.set('detection',false); for(var i=0;i<1000;i++) { juicer(tpl,data); } var endtimestamp=new Date().getTime(); var exhausttime=endtimestampstarttimestamp; document.write(juicer(tpl,data)); document.write('run time: '+exhausttime); console.log(juicer(tpl).render.toString()); console.log(exhausttime); </script> </body> </html> ![图片说明](https://imgask.csdn.net/upload/201612/16/1481872688_592055.jpg)
Identifying Legal Pascal Real Constants _course
20171013Description Pascal requires that real constants have either a decimal point, or an exponent (starting with the letter e or E, and officially called a scale factor), or both, in addition to the usual collection of decimal digits. If a decimal point is included it must have at least one decimal digit on each side of it. As expected, a sign (+ or ) may precede the entire number, or the exponent, or both. Exponents may not include fractional digits. Blanks may precede or follow the real constant, but they may not be embedded within it. Note that the Pascal syntax rules for real constants make no assumptions about the range of real values, and neither does this problem. Your task in this problem is to identify legal Pascal real constants. Input Each line of the input data contains a candidate which you are to classify. Output For each line of the input, display your finding as illustrated in the example shown below. The input terminates with a line that contains only an asterisk in column one. Sample Input 1.2 1. 1.0e55 e12 6.5E 1e12 +4.1234567890E99999 7.6e+12.5 99 * Sample Output 1.2 is legal. 1. is illegal. 1.0e55 is legal. e12 is illegal. 6.5E is illegal. 1e12 is legal. +4.1234567890E99999 is legal. 7.6e+12.5 is illegal. 99 is illegal.
The Umbrella Problem: 2054 _course
20171011Description "Forget it," Garret complained, throwing down the controller to his PlayStation VIII, "this level is impossible." He had just "died" for the 17th time on level 54 of the game "Lemmings 9: Lost in Space". "No it isn't," his brother Ferret replied, "and I can prove it." Ferret pulled his PlaySkool PDA from the back pocket of his Levi's Huggies. "First, picture the level as a rectangular grid." Ferret punched a few of the buttons on his PDA and a rectangle appeared as he described. "Your character, a Lemming holding an umbrella, starts at the top of this rectangle. His goal is to reach the bottom without dying." "I know that, you weasel, but what about the laser guns?" Garret whined. "The name is Ferret, and I was just getting to that. If we represent the level as a rectangular grid, then the Lemming can occupy one square and each laser gun can occupy a square. Remember the laser guns are cyclic: they all shoot up the first turn, right the second turn, down the third turn, left the fourth turn, and then repeat the sequence." "But you're forgetting the pits of lava!" Garret exclaimed. "You didn't let me finish. Each pit of lava also occupies a square. And each plot of grass, the Lemming's destination, can also occupy a square. Then, it's just a matter of manipulating the Lemming and laser beams in a series of turns to determine if it is possible for the Lemming to reach the bottom without 'dying'." "You think you're so smart, Ferret, let's see if you can explain that again in a clear, concise way." "Certainly": The level will consist of a grid of squares. The way each laser beam and the Lemming moves can be described in "turns". To determine if the Lemming can reach the bottom of the level without dying, Ferret devised some rules: Each turn will consist of two steps: First, the laser guns will "fire" and maintain until the end of the turn, a beam in a direction dependent on the number of the turn. On the first turn, each laser gun will shoot up (all squares directly above a laser gun are "unsafe" and cannot be occupied by the Lemming); on the second turn, each laser gun will shoot right; on the third turn, each laser gun will shoot down; on the fourth turn, each laser gun will shoot left; on the fifth turn, the sequence will repeat. Example: Column 01234 R 0 L < The Lemming will always start in a column on row 0 o 1  In this example, on the first turn, the laser beam w 2 S  will occupy squares (3,0),(3,1); second turn, (4,2); 3  third turn, (3,3),(3,4),(3,5),(3,6); fourth turn, 4  (0,2),(1,2),(2,2); fifth turn (repeating), (3,0),(3,1), etc. 5  (squares are represented using (column,row) notation) 6GPPGG< The pits of lava and grass squares will always be in the last row Second, the Lemming will always move one row down, but to any one of three columns: one column to the left, one column to the right, or remain in the same column. In the above example, on the first turn the Lemming (L) could move to square (1,1), (2,1), or (3,1) (if he moved to (3,1), though, he would die because of the laser beam). However, on any turn the Lemming cannot move outside of the grid (i.e., he cannot move to column 1, or to a column number equal to the number of columns). The level is considered "possible" if the Lemming can reach any "grass" square without dying after a series of turns. The Lemming will die if at any point he occupies the same square as a laser gun, its beam, or a pit of lava. This includes: The Lemming moving into a square a pit of lava occupies, The Lemming moving into a square a laser gun occupies, The Lemming moving into a square a laser beam occupies (even if it is a grass square!), A laser gun firing a beam into a square the Lemming occupies 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. Each data set will describe the starting conditions of the level. A single data set has the following components: Start line  A single line, "START x y", where 0 < x < 10 and x is the number of columns in the grid representing the level and 1 < y < 10 and y is the number of rows in the grid representing the level. The next y lines will represent the rows of the level, starting with row 0 (the top). Each line will consist of x letters. The letters will represent components of the level as follows: L  Lemming (there will only be one 'L' per data set, and it will always be in row 0) S  laser gun (these squares will never be in the final row) P  pit of lava (these squares will always be in the final row) G  grass (these squares will also always be in the final row) O  "empty" square of air End line  A single line, "END". Following the final data set will be a single line, "ENDOFINPUT". Output Output for each data set will be exactly one line. The line will either be "FERRET" or "GARRET" (both all caps with no whitespace leading or following). "FERRET" will appear if the Lemming can make it safely (without dying) to any grass square at the bottom of the level after a series of turns. "GARRET" will be output for a data set if it fails to meet the criteria for a "FERRET" line.
You Who? _course
20171015Description On the first day of first grade at Friendly Elementrary School, it is customary for each student to spend one minute talking to every classmate that he or she does not already know. When student Bob sees an unfamilar face, he says ``You who?'' A typical response is ``Me Charlie, you who?'' Then Bob says, ``Me Bob!'' and they talk for a minute. It's very cute. Then, after a minute, they part and each looks for another stranger to greet. This takes time. In class of twentynine or thirty mutual strangers, it takes 29 minutes; time that, according to teachers, could be better spent learning the alphabet. Of course, it is rare to have a first grade class where nobody knows anyone else; there are neighbors and playmates who already know each other, so they don't have to go through the gettoknowyou minutes with each other. The two first grade teachers have requested that, to save time, students be allocated to their two classes so that the difference in the sizes of the classes is at most one, and the time it takes to complete these introductions is as small as possible. There are no more than 60 students in the incoming first grade class. How can the assignment of students to classes be made? Your job is to write the software that answers the question. Input The school records include information about these student friendships, represented as lists of numbers. If there are 29 students, then they are represented by the numbers 1 to 29. The record for a single student includes, first, his/her student identification number (1 to 29, in this example), then the number of his/her acquaintances, then a list of them in no particular order. So, for example, this record 17 4 5 2 14 22 indicates that student 17 knows 4 students: 5, 2, and so on. The records for all the students in the incoming class are represented as the list of numbers that results from concatenating all the student records together. Spaces and line breaks are irrelevent in this format. Thus, this 1 1 2 2 1 1 is a whole database, indicating that there are only two students in the incoming class, and they know each other; and this 1 2 3 4 2 2 3 4 3 2 1 2 4 2 1 2 indicates that 1 doesn't know 2, and 3 doesn't know 4, but all other pairs know each other. The database has been checked for consistency, so that if A knows B, then B knows A. Output Your output should begin with a number that tells how long it will take to complete the introductions in the best possible legal class assignment. For the simple two student problem above, the only legal answer is 0 Sample Input 1 2 3 4 2 2 3 4 3 2 1 2 4 2 1 2 Sample Output 0
poker card game _course
20171015Description Suppose you are given many poker cards. As you have already known, each card has points ranging from 1 to 13. Using these poker cards, you need to play a game on the cardboard in Figure 1. The game begins with a place called START. From START, you can walk to left or right to a rectangular box. Each box is labeled with an integer, which is the distance to START. ![](http://poj.org/images/1339_1.jpg) Figure 1: The poker card game cardboard. To place poker cards on these boxes, you must follow the rules below: (1) If you put a card with n points on a box labeled i , you got (n ∗ i) points. (2) Once you place a card on a box b, you block the paths to the boxes behind b. For example, in Figure 2, a player places a queen on the right box of distance 1, he gets 1 ∗ 12 points but the queen also blocks the paths to boxes behind it; i.e., it is not allowed to put cards on boxes behind it anymore. ![](http://poj.org/images/1339_2.jpg) Figure 2: Placing a queen. Your goal: Given a number of poker cards, find a way to place them so that you will get the minimum points. For example, suppose you have 3 cards 5, 10, and K. To get the minimum points, you can place cards like Figure 3, where the total points are 1 * 13 + 2 * 5 + 2 * 10 = 43. ![](http://poj.org/images/1339_3.jpg) Figure 3: An example to place cards. Input The first line of the input file contains an integer n, n <= 10, which represents the number of test cases. In each test case, it begins with an integer m, m <= 100000, which represents the number of poker cards. Next, each card represented by its number are listed consecutively. Note that, the numbers of ace, 2, 3, ..., K are given by integers 1, 2, 3, ..., 13, respectively. The final minimum point in each test case is less than 5000000. Output List the minimum points of each test case line by line. Sample Input 3 3 5 10 13 4 3 4 5 5 5 7 7 10 11 13 Sample Output 43 34 110
Shredding Company _course
20171017Description You have just been put in charge of developing a new shredder for the Shredding Company Although a "normal" shredder would just shred sheets of paper into little pieces so that the contents would become unreadable, this new shredder needs to have the following unusual basic characteristics. 1.The shredder takes as input a target number and a sheet of paper with a number written on it. 2.It shreds (or cuts) the sheet into pieces each of which has one or more digits on it. 3.The sum of the numbers written on each piece is the closest possible number to the target number, without going over it. For example, suppose that the target number is 50, and the sheet of paper has the number 12346. The shredder would cut the sheet into four pieces, where one piece has 1, another has 2, the third has 34, and the fourth has 6. This is because their sum 43 (= 1 + 2 + 34 + 6) is closest to the target number 50 of all possible combinations without going over 50. For example, a combination where the pieces are 1, 23, 4, and 6 is not valid, because the sum of this combination 34 (= 1 + 23 + 4 + 6) is less than the above combination's 43. The combination of 12, 34, and 6 is not valid either, because the sum 52 (= 12 + 34 + 6) is greater than the target number of 50. ![](http://poj.org/images/1416_1.jpg) Figure 1. Shredding a sheet of paper having the number 12346 when the target number is 50 There are also three special rules : 1.If the target number is the same as the number on the sheet of paper, then the paper is not cut. For example, if the target number is 100 and the number on the sheet of paper is also 100, then the paper is not cut. 2.If it is not possible to make any combination whose sum is less than or equal to the target number, then error is printed on a display. For example, if the target number is 1 and the number on the sheet of paper is 123, it is not possible to make any valid combination, as the combination with the smallest possible sum is 1, 2, 3. The sum for this combination is 6, which is greater than the target number, and thus error is printed. 3.If there is more than one possible combination where the sum is closest to the target number without going over it, then rejected is printed on a display. For example, if the target number is 15, and the number on the sheet of paper is 111, then there are two possible combinations with the highest possible sum of 12: (a) 1 and 11 and (b) 11 and 1; thus rejected is printed. In order to develop such a shredder, you have decided to first make a simple program that would simulate the above characteristics and rules. Given two numbers, where the first is the target number and the second is the number on the sheet of paper to be shredded, you need to figure out how the shredder should "cut up" the second number. Input The input consists of several test cases, each on one line, as follows : tl num1 t2 num2 ... tn numn 0 0 Each test case consists of the following two positive integers, which are separated by one space : (1) the first integer (ti above) is the target number, (2) the second integer (numi above) is the number that is on the paper to be shredded. Neither integers may have a 0 as the first digit, e.g., 123 is allowed but 0123 is not. You may assume that both integers are at most 6 digits in length. A line consisting of two zeros signals the end of the input. Output For each test case in the input, the corresponding output takes one of the following three types : sum part1 part2 ... rejected error In the first type, partj and sum have the following meaning : 1.Each partj is a number on one piece of shredded paper. The order of partj corresponds to the order of the original digits on the sheet of paper. 2.sum is the sum of the numbers after being shredded, i.e., sum = part1 + part2 +... Each number should be separated by one space. The message error is printed if it is not possible to make any combination, and rejected if there is more than one possible combination. No extra characters including spaces are allowed at the beginning of each line, nor at the end of each line. Sample Input 50 12346 376 144139 927438 927438 18 3312 9 3142 25 1299 111 33333 103 862150 6 1104 0 0 Sample Output 43 1 2 34 6 283 144 139 927438 927438 18 3 3 12 error 21 1 2 9 9 rejected 103 86 2 15 0 rejected
Illumination _course
20171017Description You are given N light sources on the plane, each of which illuminates the angle of 2π/N with the vertex in the source point (including its sides). ![](http://poj.org/images/1902_1.jpg) You must choose the direction of the illuminated angle for each of these sources, so that the whole plane is illuminated. It can be proved that this is always possible. A light source itself casts no shadow and does not interfere with light beams from the other sources. Input The first line of the input file contains N  the number of light sources (3 <= N <= 30). Next N lines contain two integer numbers each  the coordinates of the light sources. All coordinates do not exceed 100 by their absolute value. No two sources coincide. Output ![](http://poj.org/images/1902_2.jpg) Print N real numbers  for each light source specify an angle that the bisector of the illuminated angle makes with OX axis, counterclockwise. Print at least six digits after the decimal point. No angle must exceed 100π by its absolute value. Sample Input 3 0 0 2 0 1 1 Sample Output 0.52359877559829887 2.61799387799149437 4.71238898038468986
如何从 Gmail 下载所有带附件的电子邮件？_course
20081208<div class="posttext" itemprop="text"> <p>How do I connect to Gmail and determine which messages have attachments? I then want to download each attachment, printing out the Subject: and From: for each message as I process it.</p> </div> <p>转载于:https://stackoverflow.com/questions/348630/howcanidownloadallemailswithattachmentsfromgmail</p>
 373KB
2020数学建模A题
202009112020数学建模国赛A题及其数据 2020数学建模国赛A题及其数据2020数学建模国赛A题及其数据 2020数学建模国赛A题及其数据 2020数学建模国赛A题及其数据 2020数学建模国赛A题及其数据
Java8零基础入门视频教程
20160929这门课程基于主流的java8平台，由浅入深的详细讲解了java SE的开发技术，可以使java方向的入门学员，快速扎实的掌握java开发技术！
MySQL数据库从入门到实战课
20191231限时福利1：购课进答疑群专享柳峰（刘运强）老师答疑服务。 为什么说每一个程序员都应该学习MySQL？ 根据《20192020年中国开发者调查报告》显示，超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的日常运维能力，语句调优、备份恢复等思路。
 1.16MB
微信小程序 实例汇总 完整项目源代码
20161101微信小程序 实例汇总 完整项目源代码
《C语言/C++学习指南》语法篇（从入门到精通）
20150603一门初级、从入门到精通的C语言C++语法教程，由毕业于清华大学的业内人士执课。从简单的HelloWorld入门程序，到深入的C语言C++核心概念，均为您娓娓道来，言之必详、听之必懂。让C语言C++编程变得简单，让C语言C++编程变得有趣，让喜欢C语言C++的人学会C语言C++！
 5.85MB
SimpleScalar相关介绍、论文、实验精选（共10篇）
20090331所含文章如下： simplescalar简介.pdf SimpleScalar安装报告.doc simplescalar实验.pdf Cache低功耗技术研究及SimpleScalar模拟器分析.nh
 1.70MB
200个C语言程序（由简单到复杂）
20110526从简单到难的200来个经典C程序 第一部分 基础篇 001 第一个C程序 002 运行多个源文件 003 求整数之积 004 比较实数大小 005 字符的输出 006 显示变量所占字节数 007 自增
 38.68MB
2019数学建模历年题目及优秀论文
201904022019数学建模历年题目及优秀论文 ，好资源与大家分享！！
 65.8MB
java源码包java 源码 大量 实例
20130418Applet钢琴模拟程序java源码 2个目标文件，提供基本的音乐编辑功能。编辑音乐软件的朋友，这款实例会对你有所帮助。 Calendar万年历 1个目标文件 EJB 模拟银行ATM流程及操作源代码
 博客 20201020
 博客 STM8S I2C Slave模式错误解决
 下载 php与c 实现按行读取文件实例代码
 下载 汽车电子中的一种车用电控单元散热器设计与测试
 学院 Java微信小程序手机数码商城 大学生毕业设计教学视频
 学院 项目管理工具的管理和选用
 下载 利用jquery禁止外层滚动条的滚动
 下载 注塑车间自动信息化管理系统
 博客 Spring官方二进制发布包下载地址——离线文档、jar包等
 博客 为何有越来越多资金流入BTC？BTC的“魔力”究竟在哪里
 下载 全数字控制可控硅调光LED驱动器设计
 下载 永磁同步电动机伺服系统控制策略
 博客 tomcat高版本对url特殊参数值传递问题
 学院 Vue3.0从入门到进阶实战
 博客 Hbase简答
 下载 电子维修中的谈谈电脑主板的维修方法
 学院 JavaWeb服装购物商城毕业设计 大学生毕业设计教学视频
 博客 cv2.error: OpenCV(4.3.0)cpp:376: error: (215:Assertion failed) size.width＞0 && size.height＞0 in fun
 学院 新版快速入门Android开发 视频 教程 androidstudio
 博客 内容管理（八）02删除响应无内容处理 JSONBIG.parse(null) 报错代码最好使用try{}catch(){}，弹出框确认消息组件使用
 学院 2020千锋Python入门视频全套全开源（最新版）
 下载 光网络可靠性研究
 博客 中小企业如何做好内容找到软文营销大门“钥匙”
 博客 CSV文件读写
 下载 无霍尔元件电流传感器数字交流伺服系统的设计研究
 下载 必须了解的数据中心布线五点重要知识
 下载 php cookie用户登录的详解及实例代码
 下载 电源技术中的基于设计数据共享的板级热仿真技术研究（一）
 学院 Spring AOP从认识到源码
 下载 嵌入式系统/ARM技术中的基于FPGA的SOPC系统DAB发射端硬件实现