From http://www.cppblog.com/baby-fly/archive/2010/08/03/122027.aspx? Opt = Admin
It is obviously a dynamic planning. DP [I] indicates the number of valid subsequences of the first I. So DP [I] = DP [I-1] +. A is the sum of the Number of valid
There must be at least one distance between adjacent houses and a maximum distance between adjacent houses (d). After creating a graph based on these conditions, pay attention
It depends on the relative positions of 1 and N. If 1 is on the left of
The Chinese Question is wrong.
Key Point: two people with a level gap greater than m cannot trade directly or indirectly, and 1 must be the end of the graph, therefore, the levels of all vertices in the shortest path must be in the range of [level
Matrix Multiplication Template
# Include # include # define LD _ int64struct matrix {lD a [2] [2]; void Init () {A [0] [0] = A [1] [0] = A [0] [1] = 1; A [1] [1] = 0 ;}}; matrix matrix_mul (matrix A, matrix B) {int I, j, k; matrix ans; for (I = 0;
This is also a magic graph creation question. This question fully reflects the nature of who is required for the 2-sat.
If you select a required method in a round, you need to connect an edge to the opposite point. That is, if you select a, you
DP [I] indicates the maximum probability that I will be snatched
1-dp [I] is the minimum probability of being captured.
Easy ~
# Include # include double A [110], DP [10010]; int M [110]; double max (double A, double B) {return A> B? A: B;} int
Let's summarize the two-sat in another day.
# Include # include #include #include using namespace STD; const int max = 20010; vector edge [Max]; int st [Max]; int dfn [Max], low [Max]; int top, btype, tdfn; int belong [Max]; bool INS [Max]; void
# Include # include int A [510], B [510]; int DP [510]; int main () {int T, M, N, I, j; scanf ("% d", & T); While (t --) {scanf ("% d", & M); for (I = 1; I DP [k]) k = J; if (B [J] = A [I]) DP [J] = (DP [k]> = 0? DP [k]: 0) + 1 ;}}for (I = 0; I
One of the two questions is to find a vertex so that the maximum distance between the vertex and N is the minimum value.
The other is to find a vertex so that the minimum distance between the vertex and N is the maximum.
It seems that it is not
Task: Output all words that can be composed of the other two words
For example, the ahat in the question is composed of a and hat.
Practice:
After creating a dictionary tree, split words, divide words into two sections, and then search for the
The difference constraint cleverly converts the relationship of the inequality to the triangle inequality used for finding the Shortest Path in graph theory.
That is, if dis [I] + map [I] [J]
Exchange result: DIS [I]-Dis [J]
Edge creation J->
Evaluate the pair of twin prime numbers smaller than n ....
I used a tree array and preprocessed it. Each time I input N, sum (n) is directly used to represent the logarithm of the twin prime number smaller than N.
View code
# Include #
Backpack entry question ..
View code
1 # Include 2 # Include String . H> 3 Int DP [ 12885 ]; 4 Int Max ( Int A, Int B) 5 { 6 Return A> B? A: B; 7 } 8 Int Main () 9 { 10 Int N, m, I, j, W, V; 11 While (Scanf ( " % D
View code
// Pay attention to the order of two cycles during DP transfer. W [x] (price of shoes) may be 0. If you change the order, a pair of shoes may be selected twice. # Include # Include String . H> Int DP [ 11 ] [ 10010 ]; Int Belong [
2-Sat entry question, just create a template after creating a graph
At the beginning, two sides were connected, dizzy .....
# Include # include #include #include using namespace STD; const int max = 10010; vector edge [Max]; int st [Max];
For more information, see here.
Http://www.cnblogs.com/lotus3x/archive/2009/03/21/1418480.html
Dichotomy:
/* The length of the channel is the horizontal distance between the two ages. the cost of the channel is the height of the lifter. optimal
Segment tree interval dyeing to determine the number of color ranges
Typical segment update and lazy thinkingView Code
# Include # Include # Include Using namespace std;Const int maxn = 100010;# Define lson l, m, rt # Define rson m + 1, r, rt Int
Comment in the code
Two Tree arrays, or two
The first maintenance is the vacant location, update, update the number of vacant locations within the jurisdiction, getk obtains the number of the k empty location, in fact, is the k decimal, and then
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service