Test instructions: From the 1th person to send the letter to the nth person, each person at most back to the M-person, ask how many kinds of programs to the nth person.
Problem-solving ideas: Water problem, dp[i] means to the first person how many kinds of programs, dp[i] + = Dp[k], i-m
#include
http://acm.hdu.edu.cn/showproblem.php?pid=4089
There are doubts that need to be re-pushed:But what you learned:1, a=a+b+c ABC is three kinds of situation, then P (A) =a*p (a-> event) +b*p (b-> event) +c*p (C-> event);
The A-> event means that the event in a case is the thought of the full probability formula.
2, must pay attention to each step will not appear in the denominator of 0, and pre-processing time for some special circumstances cause their own formula will appear in the denominator of
As long as this problem is selected i,j then either the horizontal, or the column is the i,j before the row all selected, cannot turn.
So each update corresponds to a length or width extension of 1 from an existing rectangle, then the state equation can be defined as Dp[i][j]=max (Dp[i-1][j]+row[i][j],dp[i][j-1]+col[i][j]).
#include
2302: [Haoi2011]problem C Time limit:30 Sec Memory limit:256 MBsubmit:937 solved:509[Submit] [Status] [Discuss] Description to the n person to arrange a seat, first give each person a 1~n number, set the first person's number is AI (different person's number can be the same), and then from the first person to start, everyone in turn seated, I personally came to try to sit after the AI, if the AI was occupied, If you try to ai+1,ai+1, you try to ai+2, ..., if you try to get to Nth, the arrangemen
Description
Ashen ready to enroll in the GT exam, the ticket number is n-digit x1x2....xn (0Input
The first line enters N,m,k. The next line is to enter the number of M bits. 100% data nOutput
Ashen want to know how many kinds of numbers do not appear unlucky numbers, the result of output modulus K redundancy. Sample Input
4 3
111
Sample Output
81
HINT
Source
Set DP[I][J] The number of schemes that match the first number of numbers to the fi
Probability:POJ 2151There is a T-team, M-problem, give each team to make each problem probability. Find out that each team has at least one problem and the championship team has at least the probability of making n questions.Each team has at least one problem in the opposite incident is that each team to make at most 0 questions. Therefore, each pair must be asked to make 0 probabilities.The odds of a champion team making at least n questions is that all teams make the most of the n-1, so it is
Title Address:pid=5067 ">hdu 5067The classic TSP traveling salesman problem model.Pressure DP.The distance from each of the two gravel piles is first preprocessed separately. Then turn the title into a minimum time model for every city in 10 cities at least once. Then a simple pressure DP is available.The code is as follows:#include 0:MIN1); } return 0;} HDU 5067 Harry and Dig machine (pressure dp) (TSP pro
Title Address: HDU 5067The classic TSP traveling salesman problem model. Pressure DP.The distance from each of the two gravel piles is first preprocessed separately. The problem is then transformed into a minimum time model for every city in 10 cities at least once. Then the simple pressure DP can be.The code is as follows:#include HDU 5067 Harry and Dig machine (pressure dp) (TSP problem)
https://leetcode.com/problems/house-robber/The topic designed a robber's scene, in fact, is to find the array of nonadjacent data combined to get the maximum valueGive an exampleHypothetical data: 8 3 6 15 4 9 7 10Then the first possible choice is 8, 3Each number is selected according to his first two numbers, the first three numbers to get the maximum value to choose, until 6 when considering the front can only and 8 combination 8,3,14To the number 15, you can consider combining 8,3,14,23,4,9,7
that the first time to know the invasion of foreign enemies. The Goblins hope that each section of the N-section of the mountain can be built into one of the observatory or tavern, and only the entire mountain range that satisfies this condition may be inhabited by the goblins. Now you want to know how many kinds of mountain ranges may be inhabited by N in length. Two Mountains A and b are different when and only if there is an I, which makes Ai≠bi. Since this number may be large, you are only
sequence of the first and the end elements.Sample Input6-2 11-4 13-5-210-10 1 2 3 4-5-23 3 7-2165-8 3 2 5 01103-1 -5-23-1 0-20 Sample Output1310 1 410 3 510 100-1 -20 0 0HintHintHuge input, scanf is recommended.SOURCE Zhejiang University Computer Postgraduate exam on the machine-2005recommendjgshining | We have carefully selected several similar problems for you:1003 1087 1176 1203 1257Undoubtedly, the most common sub-series of the problem, the test is dynamic programming, that is,
HDU 5067 Harry and Dig machineIdea: Because the point is only 10, in addition to a starting point, processing out of the Manhattan distance between each point, and then using the pressure DP to engage, the state is expressed as:Dp[i][s], indicating the minimum cost of the set of points traversed at I positionCode: #include HDU 5067 Harry and Dig machine (pressure DP)
Topic links\ (description\)Each point has a cost Si and value pi, which requires selecting some connected blocks with a root, the total size is k, making \ (\frac{∑pi}{∑si}\) the largest\ (solution\)01 Fractional plan, then DP, set F[I][J] indicates the maximum weight of the I subtree selected J and, direct violent backpack transfer can beWhen enumerating the number of child nodes selected, assume X has 1.2.3.4 four child nodes with a complexity of \
Meaning
n A tree of city nodes, the electricity loss of node I to Node J is i*i*r* (number of edges in the path of I to J), and now a power station is built at a node to minimize the total loss of this node to all other nodes.
Ideas
A typical tree DP
You can first use DFS to find out the number of subtree nodes per point num[u], and each point to its subtree all nodes of the total distance f[u][0];
Then with a DFS, the total distance of each node
Meaning
to an N-node tree, the distance of any two nodes refers to the shortest number of edges connecting two points.
There is a "demon book" on a node in the tree, and this book will affect the nodes within D.
Known to have m nodes received an impact, ask a maximum of several nodes may have "demon book"?
Ideas
To determine whether a particular point is placed on a book, determine if any of the affected m nodes are included within d distance around the point.
And if a node is farthest from the
The CLS is a good early question ... Very classic Ah ...For a string s s with a length of n N, how many string T t of length M M makes the LCS (S,T) LCS (s,t) 0,1...N 0,1...N respectively.
We want to be able to use a f[j][{lcs[1][j],lcs[2][j],lcs[3][j]...lcs[n][j]}] f[j][\{lcs[1][j],lcs[2][j],lcs[3][j]...lcs[n][j]\}] To represent the current state to calculate the answer.At first it seems to be trying to directly use the subsequence to allow the ... Will find it difficult and not too right. So g
Not strictly simple, in fact, the strict can be converted into less stringent:Iis to meet ai−i a_i-i not strictly increase the good.The less stringent approach is to direct DP DP, the value of the change must be the original number, the value of the number of O (n) o (n). The direct Fi,j F_{i,j} indicates that the number of first I I is incremented, and the number of I I is the minimum cost of J J. Transfer
This is an upgraded version of 51nod1383. n N is 1030 10^{30}The approach is a fantastic DP DP. Consider under the binary system.Fi,j F_{i,j} indicates that the maximum number of 2i 2^i is the number of scenarios when 2j 2^j.Transfer is fi,j=fi−1,k+fi−1−k,j−k f_{i,j}=f_{i-1,k}+f_{i-1-k,j-k}Then there is a similar merge per bit. Gi,j G_{i,j} represents the number of scenarios in which the maximum number of 2
Topic Link:
Http://codeforces.com/problemset/problem/401/D
D. Roman and Numbers time limit/test 4 seconds memory limit per test megabytes input standard input output Standar D Output
Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn ' t. To make Sereja the change he mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers the close to number N, are M.
Number x is considered close to number n modulo m
This game is relatively simple, each person's goal is only to let their own points more. So direct DP DP Request:Set fi,0 f_{i,0} to represent the first pick from I I, the best value of the upper tempo. fi,1 f_{i,1} is the optimal value of a.Obviously there are fi,0=max{aj+fj+1,1} f_{i,0}=max\{a_j+f_{j+1,1}\}, fi,1=fpos,0 f_{i,1}=f_{pos,0}. Pos POS indicates where the fi,0 f_{i,0} is transferred from.
#inc
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.