Analog Test 67

T1:

  Seeking to meet $ (a + b) <= n $ and $ n | ab $ logarithmic number.

  The answer is represented by the formula:

    $\begin{array}{rl} ans &=& \sum \limits_{i=1}^n \sum \limits_{j=1}^n [i+j|ij][i+j<=n] \\ &=& \sum \limits_{i=1}^{n-1} \sum \limits_{j=1}^{n-i} [i+j|ij] \end{array}$

  Provided $ g = gcd (a, b) $, when the $ \ frac {a + b} {g} | when g $, satisfy the conditions.

  Proof:
    If $ a + b | ab $, then $ \ frac {a + b} {gcd (a, b)} | \ frac {ab} {gcd (a, b)} $.

    设$a'=\frac{a}{gcd(a,b)},b'=\frac{b}{gcd(a,b)}$。

    Provisions $ a '+ b' | a'b'gcd (a, b) $.

    Because $ a '$ and $ b' $ prime, $ a '+ b' | gcd (a, b) $.

  Logarithm to meet the conditions as follows:

    $ans=\sum \limits_{i=1}^{n-1} \sum \limits_{j=1}^{n-i} [i+j|gcd(i,j)]$

  Enumeration gcd:

    $\begin{array}{rl} ans &=& \sum \limits_{g=1}^{\sqrt{n}} \sum \limits_{i=1}^{\lfloor \frac{n}{g} \rfloor} \sum \limits_{j=1}^{\lfloor \frac{n}{g} \rfloor -i}[gcd(i,j)==1][i+j|g] \\ &=& \sum \limits_{g=1}^{\sqrt{n}} \sum \limits_{i=2}^{\lfloor \frac{n}{g} \rfloor} \sum \limits_{j=1}^{i-1} [gcd(j,i-j)==1][i|g] \end{array}$

  From the Decreases Technique:

    $ Gcd (x, y) == gcd (and x) $

  and so:

    $\begin{array}{rl} ans &=& \sum \limits_{g=1}^{\sqrt{n}} \sum \limits_{i=2}^{\lfloor \frac{n}{g} \rfloor} [i|g] \sum \limits_{j=1}^{i-1} [gcd(i,j)==1] \\ &=& \sum \limits_{g=1}^{\sqrt{n}} \sum \limits_{i=1}^{\lfloor \frac{n}{g} \rfloor} [i|g] \varphi(i) \\ &=& \sum \limits_{g=1}^\sqrt{n} \sum \limits_{d|g} \varphi(d) \\ &=& \sum \limits_{d=1}^{\sqrt{n}} \lfloor \frac{n}{d^2}\rfloor \varphi(d )\end{array}$

  Linear sieve out the $ \ varphi $ can.

  Time complexity $ O (\ sqrt {n}) $.

T2:

  Rise longest subsequence problem.

  With the number of array shape optimized to achieve the complexity of $ nlogn $.

  Take several statistical programs, the number of array-like structures are installed, continue to merge, find the number of programs under the optimal conditions of the current point, and then transferred.

  Time complexity $ O (nlogn) $.

T3:

  Fibonacci numbers, be sure to use Fibonacci number.

  Have three arrays, $ dp [i] $ denotes the Fibonacci, $ f [i] $ I $ denotes the white point of the layer $, $ g [i] $ represents black points.

  Three arrays can be obtained through a recursive, reprocessing and a prefix.

  Points of discussion:

    If lca in which a white point, the processing directly subtree and the white points, each layer into the white point.

    lca nodes are black, enumeration path length, depth and a pitch lca, other points may be calculated in other cases.

    You can then learn the height range of black nodes, multiplied by black dots can be.

  Time complexity $ O (n ^ 2) $.

Guess you like

Origin www.cnblogs.com/hz-Rockstar/p/11664729.html
67