- Given \ (n-\) number, with minimal \ (2 ^ k \) or \ (- 2 ^ {K} \) , such that all data can spell, output scheme. \ (the n-, | a_i | \ Leq 10 ^ 5 \) .
Surely an absolute value option at most once. This property is very strong.
If all are even, it can be directly divided by \ (2 \) .
Otherwise \ (1 \) or \ (- 1 \) must choose, choose violent enumerate which then recursively, to each weight, most will find recursive \ (\ log a \) times. Overall complexity \ (O ((n-+ A) \ n-log) \) , equivalent to the sum of the length of the line segment tree.
- \ (n \) number, each time you can spend \ (1 \) costs on a number \ (+ 1 \) or \ (- 1 \) , do not ask to become a sequence of rising minimum price. \ (n-\ Leq. 5 \ ^ 10. 5 Times \) .
It is equivalent to the sequence does not decrease.
Set \ (f (x) \) represents the last number \ (leq x \ \) optimal answer when. It is clear that several segments shaped like an integer fold line slope, and the slope of the drop is not continuous.
Was added rightmost \ (A \) , each position plus \ (| XA | \) , and \ (f (x-1) \) take \ (\ min \) .
Only need to maintain the turning point, two inflection points each addition and deletion of the biggest one.
Finally, \ (\ f (0) = \ sum | | a_i) reduction answer.
- Consider all positive integers re-set \ (\ {A_1, ..., a_k \} \) , satisfies \ (\ SUM n-a_i = \) , require that all \ (\ sum a_i ^ m \ ) and. \ (n-, m, K \ Leq 4096 \) .
Set \ (f_ {i, j} \) representing the forward \ (I \) number, and for the \ (J \) number scheme. Each transfer or put a \ (1 \) at the end of, or all number-average \ (+ 1 \) .
Dp violence can maintain each number \ ([0, m] \ ) times and transfer time multiplied by the number of combinations. Complexity \ (O (n-^. 4) \) .
Point decline optimization is to maintain the power of each number (the number of combinations can seem), and finally reductive answer with a second Stirling number, so that a single transfer is \ (O (1) \) , the complexity of \ (O (n-^. 3) \) .
Consider the contribution of each number generated how many times. Found that \ (\ sum_j [i \) appears at least \ (j \) the number of times a program of \ (] \) .
This can be \ (f_ {i, j} \) operator is not required when dp statistical answer. Complexity \ (O (^ n-2) \) .
- Given \ (A_1 \) to \ (A_n \) , provided \ (F_k = \ sum_ = {I}. 1 na_i ^ ^ K \) , seeking \ (of F_1, ..., F_n \) . \ (n-, K \ Leq 2 \ ^ 10. 5 Times, a_i \ Leq. 9 ^ 10 \) .
Newton identities: for monic polynomial \ (F. (X) = \ sum_ {I = 0} ^ NC_ {Ni} X ^ I \) , provided \ (P_i \) for its \ (n-\) th root \ (I \) th power and, for any positive integer \ (D \) , of equation
\[\sum_{i=0}^{d-1}C_i P_{d-i}+C_d\cdot d =0\]
By the \ (C \) seeking \ (P \) : inverse polynomial; manufactured by \ (P \) seeking \ (C \) : polynomial \ (\ exp \) .
This problem hard point \ (a_i \) is a polynomial \ (n \) root, divide and conquer fft obtained polynomial, inverse can be. Complexity \ (O (n-\ log ^ 2N) \) .
- \ (n-\) points, \ (m \) strips weighted undirected edge weights \ (\ in [0,17) \) , asked how many kinds of programs to select some of the edges (not selected multiple edges), such that FIG whole Unicom, and the right side and \ (\ equiv X (\ MOD P) \) . To \ (x \ in [0,17) \) are required to answer. \ (n-\ Leq. 17, m \ Leq. 5 ^ 10 \) .
Clearly a circular convolution, before the DFT, with the end of the calculation point values and then back to IDFT.
Consider inclusion and exclusion, by subtracting the total number of programs do not communicate. Enumeration \ (1 \) communication block where the inclusion and exclusion complexity \ (O (^ NP. 3) \) .
\ (O (2 ^ nn ^ 2p) \) practice a little trouble generating function requires great skill, it is down.
- Given \ (n-\) number \ (a_i \) and \ (m \) , find the smallest \ (K \) , so that there is a length \ (\ geq m \) interval, such that any number in the interval , another number can be found in the section and it does not exceed \ (k \) . \ (n-, m \ Leq. 5 ^ 10 \) .
Dichotomous answer for each number of recently obtained about the condition of the position, is set to \ (L_i, R_i \) .
Determines whether there is transformed into the \ ([L, R & lt] \ GEQ m \) , such that any element within the range satisfying \ (L_i \ geq l \) or \ (R_i \ R & lt Leq \) .
Set \ (solve (l, r) \) represents \ ([l, r] \ ) whether there subinterval satisfying the condition.
If \ (L-R & lt +. 1 <m \) , is clearly not.
If a point \ (L_i <l \) and \ (R_i> R & lt \) , this point is not selected, recursive process \ (Solve (L, I-. 1) | Solve (. 1 + I, R & lt) \) .
Violence sweep is from left to right \ (O (n ^ 2) \) , the two sides to the middle sweep consideration, it is found return, this is \ (T (n) = T (i) + T (ni) + O ( \ min (i, ni)) \) , the overall complexity \ (O (n-\ log ^ 2N) \) .
- \ (n \) kinds of items, each item weight \ (w_i \) , the value of \ (v_i \) , there are an infinite number. \ (q \) once asked each time to ask all the weight exactly \ (m \) scheme, the maximum value is how much, spell out the value of this program is the number of how many. Different order counted different schemes. \ (n-, W_i, Q \ Leq 100, m, V_I \ Leq. 9 ^ 10 \) .
Since the need to consider the order of the number of programs can be directly DP, \ (F_i = \ max (F_ {} + I-w_j w_j) \) , while the number of programs can be updated.
We found \ (w_i \) does not exceed \ (100 \) , namely that only the most recent \ (100 \) is useful states. With \ (\ max \) define addition and multiplication defined by addition, it is found by moment variant.
Done directly \ (O (n-^. 4 \ log m) \) . Consider a pre-transition matrix \ (2 ^ k \) power, with each vector multiply \ (O (\ log m) \) matrix, overall complexity \ (O (n ^ 3 \ log m) \ ) .
- Given \ (A, N, P \) , for all \ (U \) from seeking \ (1 \) to \ (\ lfloor \ frac {A } {2 ^ u} \ rfloor \) selected \ (n-\) number, \ (. 1 \ n-Leq \ Leq N \) , and \ (n-\) is an odd number, and the selected maximum number is odd, the number of programs seeking & summation. For \ (P \) modulo. \ (A \ ^ Leq 10. 9, N \ Leq 30000, P = O (10 ^. 5), Time = 5000ms \) .
After the maximum number of enumeration, seeking to become the number \ (n \) great, \ (m \) small number of combinations.
The number of combinations can partition: \ (C (n-, m) = \ sum_ {I = 0} ^ mC (X, I) \ CDOT C (NX, Ni) \) , where \ (X \) may be any \ ([1, n] \) number.
In this is the \ (A \) divided in half, and then processed recursively combined fft.
Because every time divided by \ (2 \) rounded down, so again you can calculate all \ (u \) answers. Complexity \ (O (n-\ log n-\ log A) \) .
- Given \ (S [0 ... 5] , \) each number is "front" / "medium" / "rear." There are a binary tree is defined \ (the DFS (the X-, the MODE) \) , where \ (mode \) indicate what kind of way. However, when the left and right recursion Son, becomes \ (DFS (L, S [2 \ Times MODE]), DFS (R & lt, S [2 \ Times MODE +. 1]) \) . The results are given two kinds of traversal, seeking a possible third traversal results. \ (n-\ Leq 100 \) .
Set \ (f_ {x, y, a, b, i} \) is the first sequence \ ([X, X + I] \) , way \ (A \) , the second sequence \ ([Y , Y + I] \) , way \ (B \) is legitimate.
If the two are equal way, direct sub-string is exactly equal.
If a traversal sequence is to be processed recursively.
Otherwise you need to enumerate son around the dividing line.
It appears \ (O (n-^. 4) \) , in fact, the first interval is determined sequence, a second sequence of up to the corresponding section is legitimate (identical set point). Therefore, the total complexity of the \ (O (n-^. 3) \) .
- \ (n-\) points \ (m \) without edges to FIG. \ (Q \) operations, the two sides each exchange number, answered by number from small to large plus side, when the number is much Unicom added. \ (n-, Q \ ^. 5 Leq 10 \) .
Set \ (work (l, r) \) represents the \ ([l, r] \ ) changes, modifications and answer After each answer.
The modification involves side to \ (\ INF \) , run the minimum spanning tree, this time not one side (unmodified) has been useless, deleted directly. At this time, the number of edges is \ (O (\) points \ () \) .
Relates to the modification of side \ (- \ INF \) , running a minimum spanning tree, in the case where a certain side of useful direct compression point. At this points to \ (O (RL) \) .
Recursive processing on both sides, each side to sort. Complexity \ (O (n-\ log ^ 2N) \) .
- \ (n-\) points, \ (m \) edges of a simple graph, each point degree is not more than \ (7 \) , to the point of four staining, requires that each point up to a neighbor and it is the same. Program output has no solution. \ (n-\ 25000 Leq, m \ Leq. 5 ^ 10 \) .
With an initial solution, then adjust.
Find a point conditions are not satisfied, we put it into a viable color. Because the degree is not more than \ (7 \) , so be sure feasible.
Queue Simulation with this process, after each adjustment, both ends of the same side of the color will decrease, so will end. Complexity \ (O (m) \) .