Euclidean
Ll gcd (ll a, LL B) {return (B = 0 )? A: gcd (B, A % B );}
Extended Euclidean
Int ex_gcd (int A, int B, Int & X, Int & Y) {// returns the maximum approximate number if (B = 0) {x = 1; y = 0; return A;} int d = ex_gcd (B, A % B, x,
Improved Hungary water over Ms ....
# Include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include using namespace STD; # define ll
DP [k] [0] indicates the minimum number of knots required for the subtree with K points as the root (K is not used). Similarly, DP [k] [1] indicates the minimum number of knots required for the subtree with K points as the root (k-Fetch). If the
It can be km, or charge, and recently the tuition fee is used. So it is a waste of time to use DEBUG. I thought there was a problem with spfa. It turns out there was an error in counting... Sorry, the food, the saying is that poj 2516 still does not
Http://poj.org/problem? Id = 1141
DP to find the optimal solution.
# Define n 110 char STR [N]; int DP [N] [N]; // the minimum number of characters inserted between I and j. Int tag [N] [N]; // record the location where characters need to be
Int max (int A, int B) {return A> B? A: B;} int DP [110] [110]; int main () {int N, T; while (scanf ("% d", & N, & T )! =-1) {int I, j, k; memset (DP, 0, sizeof (DP); for (I = 1; I = W; j --) {DP [I] [J] = max (DP [I] [J], DP [I] [J-W] + V ); //
Http://acm.ustc.edu.cn/ustcoj/problem.php? Id = 1280
This is the subject of the China University of Science and Technology's "age point technology Cup" ACM New Year's Eve challenge. At that time, I couldn't do it. Later I Thought About It. tle1, WA
Fuck !!! Wa is dead. I don't know where it is... Put it first
# Include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include using
Spoj694 http://www.spoj.pl/problems/DISUBSTR/
Spoj705 http://www.spoj.pl/problems/SUBST1/
The two questions are similar, but only 705 of the data is a little bigger. There is no pressure to use the multiplier algorithm. Continue to set the template.
KMP template question, not easy to understandMatrix67's blog complexity allocation is O (n)
# Define n 1000010 char W [10005]; // short stringchar T [1000005]; // long stringint P [10005]; // array P [J], indicates the maximum number of int sum;
Spoj 687
# Include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include using namespace STD; # define ll long # define PII pair #
Understand the meaning of the P array in the KMP algorithm (commonly used next array, but I used to name it p ^_^). The meaning of the P array is the same as that of the maximum K characters in the prefix, therefore, finding J = P [J] from the last
The following describes how to use a few taxis to complete n tasks:Minimum path Overwrite= Points-Maximum number of matches, here there is a detail http://www.cnblogs.com/ka200812/archive/2011/07/31/2122641.html of attention
#include #include
How many repeated strings exist in a string? If the result of ababab is 3, A = AB.
Method: The array P [I] is obtained through KMP preprocessing. It is easy to obtain that the length of a is len-P [Len].
#include #include #include #include #include
This is similar to poj 2752. Because prefix is required, you need to traverse from the beginning to the end to find each prefix that meets the requirements.
#include #include #include #include #include #include #include #include #include #include
Strange, this question is modified by poj3080 and AC, but it cannot be used in poj3080. It is strange to say that... Is the RP of Brother's low to this ?!
#include #include #include #include #include #include #include #include #include #include
Question A and question B.
C: brute-force enumeration L ~ R between the lucky number, because there are a maximum of 1500 lucky number, so you can be bold and violent!
Note int Overflow
#include #include #include #include #include #include #include
Start Sb-based violence, that is, enumerating a string, and the result is Sb-based TLE...
Later I found that I am really Sb, and I did not take advantage of the elegant nature of KMP at all. In the main program of KMP (the main program and the
Pay attention to this question. The question says you should notice that the roads of two different robots may contain some same point. is to pay attention to this detail http://www.cnblogs.com/ka200812/archive/2011/07/31/2122641.html, to use a
F [I] [J] [2] indicates that the number of the first I ends with the number of J, 0 indicates the trough, and 1 indicates the peak.
Transfer equation: F [I] [J] [0] = max (F [I] [J] [0], f [I-j] [k] [1] + 1 );
F [I] [J] [1] = max (F [I] [J] [1], F
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