at least a few times can determine this KTitle Analysis: Dp[i][j] indicates that the first layer of I have only J ball and in the worst case to determine the number of times K, then we can enumerate the middle K, assuming:The K-layer falls broken then dp[i][j] = Dp[k-1][j-1] indicates that the K-level has been confirmed, there are k-1 layer, because a broken one, and left J-1The k layer falls not broken then dp[i][j] = Dp[i-k][j] means that the layer K and below will not be broken, and the rema
); theCin>>op; Aboutres[a][b]=C; the intt=Mapp[op]; the //set I*2 to 0,i*2+1 for 1 the if(t==1)// and + { - if(c==0)//1 of them must be 0 . the {Bayivect[a*2+1].push_back (b*2); thevect[b*2+1].push_back (A *2); the - } - Else //both must be 1 the { thevect[a*2].push_back (A *2+1);//point to yourself thevect[b*2].push_back (b*2+1); the } -
Round-table lamp
The king is preparing to hold a round-table meeting to discuss the exile of Merlin. There are n seats in the Round Table. Each seat has a desk lamp on the desktop. Some are on and some are closed. Round-table meetings can only be held when all desk lamp is turned on. The king can only list the sequence numbers of the lamp to be operated on paper and let the servant operate. Merlin can see the contents of the King on paper in the crystal ball and turn the Round Table. Assuming
Statistical puzzlesTime limit:4000/2000 MS (java/others) Memory limit:131070/65535 K (java/others)Total submission (s): 19292 Accepted Submission (s): 8518Problem Descriptionignatius recently encountered a problem, the teacher gave him a lot of words (only lowercase letters, no duplicate words appear), now the teacher asked him to count the number of words prefixed with a string (the word itself is also its own prefix).The first part of input data is a Word table, one word per line, the length
of mod 10^10+9, and you can roughly assume that the answer is no more than 10^10 when and only if the answer is calculated two times.F[X][Y]=A[I][J] (1F[x2,y2]-f[x1-1][y2]-f[x2,y1-1]+f[x1-1][y1-1].First we can see that for f[x][y], when x=y, you can calculate directly O (1) (arithmetic progression and formula). Then, when the x!=y, there is a part of the direct calculation is not part of the opposite, each row is a number of consecutive numbers (the same as the same column), the first row and s
Interval DP Basic problemPost Code only#include Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. POJ 1651:multiplication Puzzle
Title: http://poj.org/problem?id=1651Water problemTest instructions: A number of cards, the score of the first card is a[i] (1 n cards, in addition to the first and last card is not available, you can take one, get the score a[i–1] * a[i] * a[i + 1], and then the card removed. The title requires the final calculation of the minimum total score. Principle: Matrix multiplication.1#include 2#include 3#include 4#include string.h>5 using namespacestd;6 Long Longdp[ the][ the],a[ the],tmp;7 8 intMain
can think in turn-- first we destroy all the planets we want to destroy, we calculate the number of connected blocks at the last moment, and then we add them to the order of the topic, and each time the planet is added, it merges all the planets connected to the same connected block. In this way, we don't have to think about their previous state. The process of incorporation is completed by using and checking the set. 4. Code----------------------------------------------------------------------
#include int main (){int n,i;while (scanf ("%d", n)!=eof){int t,min,max=0;scanf ("%d", t);min=t;for (i=1,max=0;i{scanf ("%d", t);if (T-min>max)Max=t-min;if (tmin=t;}printf ("%d\n", Max);}}In a column number, the difference is the largest (minus the previous)/* Tle Timeout code#include int main (){int n,i,j,max,a[10010];while (~SCANF ("%d", n)){for (i=0;iscanf ("%d", a[i]);for (i=0,max=0;ifor (j=i+1;j{T=a[j]-a[i];if (T>max)max=t;}printf ("%d\n", Max);}}*/Nyoj 739 Idiot
Statistical puzzlesTime limit:4000/2000 MS (java/others) Memory limit:131070/65535 K (java/others)Total submission (s): 23029 Accepted Submission (s): 9640Problem Descriptionignatius recently encountered a problem, the teacher gave him a lot of words (only lowercase letters, no duplicate words appear), now the teacher asked him to count the number of words prefixed with a string (the word itself is also its own prefix).The first part of input data is a Word table, one word per line, the length
Title: http://acm.hdu.edu.cn/showproblem.php?pid=5411Test instructions: According to the title of the conversion means, given N and M, and then give some side (u,v) to indicate that U and V are connected, ask the number of 0,1,2.....m steps.Analysis: This problem and hdu5318 the goddess of the Moon, is more than a geometric series sum. Code:#include Hdu 5411 CRB and Puzzle (Matrix Fast Power optimization DP)
Title Link: http://poj.org/problem?id=1651Test instructions: A series of numbers, in addition to the tail can not move, each time take out a number, this number and left and right adjacent numbers of the product for its value,Finally add up all the values and ask for the minimum value.It is easy to think of greed is to first take the largest number first out so that you can meet the remaining total value as small as possible, if there are multipleThe number of time priority to take away the valu
} the voidDFS1 (intXintPintID) {111 for(inti=last[x];i!=-1; i=e[i].prev)if(e[i].to!=p!E[i].vis) { the if(ABS (size[e[i].to]-(siz-size[e[i].to)) tmp) {113Id=i; theTmp=abs (size[e[i].to]-(siz-size[e[i].to])); the } the DFS1 (e[i].to,x,id);117 }118 }119 voidDFS2 (intXintPintd,vectorint>a) { - if(!white[x]) a.push_back (d);121 for(inti=last[x];i!=-1; i=e[i].prev)if(E[i].to!=p!e[i].vis) DFS2 (e[i].to,x,d+e[i].w,a);122}View CodePostScriptThe first tree divided, so de
Ideas:1. If the color of the former n-1 is eligible, then there are only 1 ways to join one because of the difference in the first and last, s[n] = s[n-1]2. If a string consisting of a former n-1 is not met, then it is lawful to join one. That is, because the end of the same caused by the illegal, then the string of the former n-2 is bound to be legal. At this point there are 2 ways to add the nth bit. ie s[n] = 2*s[n-2]So the AC code:HDU 2045 Not Easy Series (3)--lele RPG
scheme.InputThe first behavior n, the second row has n number, in order the number of the second column in the lattice. (1OutputA number, that is, the number of thunder in the first column.Sample Input21 1Sample Output2Analysis: By the second column gives you the hint, obtains the first row thunder the possibility. The students who have played mine clearance may be aware that this problem can only be reached in the first two, and there is only one possibility behind the Thunder. the dp[can be d
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.