79 analog solution to a problem

A. tree

The problem is to find a tree maintenance monotonous stack ancestor chain, respectively, then two values, and depth of decentralization.

As it has been done a similar problem,

Based maintain a direct multiplier divided by two link stack (or may be called monotonous persistence stack?) Would be finished.

 

 

 

B. ring circle

One conclusion is that: in the tournament, either present in the ring, or present in the smallest ring of three-membered ring.

Although unexpected, but correctness is obvious, because every edge between any two points.

So the question is converted to three-membered ring count, this can be treated with $ bitset $.

In the tournament, the more correct approach is positive then the hard contrast, consider how the three points do not constitute a three-membered ring.

First, the number of three-membered ring not exceeding $ C_n ^ 3 $,

For three points not constitute a three-membered ring, must satisfy: and there exists only one point out of two edges directed points.

So the problem is solved.

 

 

 

C. gift gift

Consider how $ n ^ 2 $ violent enumeration $ (i, j) $ optimization, the number of combinations might separating section on both the $ i $, $ j $ a.

Might launch a convolution type, that is, $ a_i + b_i $ selected $ k $ th, at $ a_j + b_j $ select $ a_i + a_j-k $ th, then over.

Positive Solutions of clever use of the convolution type, but still can not think.

Tip data ranges we can enumerate $ a $ and $ b $.

So long as the barrel recorded in about $ a_i + b_i $ selected $ k $ a contribution to the cause of the enumeration to $ j $ violent when Charles barrel on it.

Guess you like

Origin www.cnblogs.com/skyh/p/11708299.html