Analog Test 57

T1:

  Intimate send sub-themes.

  For each color, if more, how will the number two in addition to the contribution, otherwise there will be a small amount of demand.

  Finally, whether the contributions and needs which can be large.

  Time complexity $ O (1) $.

T2:

  Too many edges, considering the state of the record at the point.

  Each possibility is a dag, the topology can be layered sequence.

  The state of the currently selected record set set point and the last layer, and then status updates to enumerate.

  Calculate the current collection to expand the collection even number of sides, each point must have at least one side of the update.

  Consider optimization, eliminating the need for second-dimensional state.

  Enumeration set up a subset of, calculate the current collection to expand the set of even number of sides , each side can be with or without.

  But this would be considered heavy, because each calculated program does not necessarily connected to expand the set of all points.

  According to the number of points about the inclusion and exclusion, Qijia can even cut.

  Note enumerate a subset of internal circulation can no longer count the number of sides, from small to large subset of enumeration, you can do a little of recurrence.

  Time complexity $ (3 ^ n + m2 ^ n) O $

T3:

  God Mobius inversion problem.

  LCM is greater than $ $ $ $ n-logarithm of seeking bad, consider seeking less than $ LCM $ $ $ n-logarithmic number.

  Such calculated based on the number of number of $ res $, then the answer can be expressed as:

    $ Year = $ n ^ 2-res

  Consider seeking $ res $:

    $\large \begin{array}{ll} res &=& \sum \limits_{i=1}^n \sum \limits_{j=1}^n [lcm(i,j)<=n] \\ &=& \sum \limits_{d=1}^n \sum \limits_{i=1}^{\lfloor \frac{n}{d} \rfloor} \sum \limits_{j=1}^{\lfloor \frac{n}{id} \rfloor} [gcd(i,j)==1]*[ijd<=n] \\ &=& \sum \limits_{d=1}^n \sum \limits_{i=1}^{\lfloor \frac{n}{d} \rfloor} \sum \limits_{j=1}^{\lfloor \frac{n}{id} \rfloor} \sum \limits_{g|gcd(i,j)} \mu(g) *[ijd<=n] \\ &=& \sum \limits_{d=1}^n \sum \limits_{g=1}^{\lfloor \sqrt{ \frac{n}{d}} \rfloor} \mu(g) \sum \limits_{i=1}^{\lfloor \frac{n}{dg^2} \rfloor} \sum \limits_{j=1}^{\lfloor \frac{n}{idg^2} \rfloor} [ijdg^2<=n] \\ &=& \sum \limits_{g=1}^{\sqrt{n}} \mu(g) \sum \limits_{d=1}^{\lfloor \frac{n}{g^2} \rfloor} \sum \limits_{i=1}^{\lfloor \frac{n}{dg^2} \rfloor} \sum \limits_{j=1}^{\lfloor \frac{n}{idg^2} \rfloor} [ijdg^2<=n]\end{array}$

  发现$d$,$i$,$j$并没有本质区别,于是我们可以假定$d<=i<=j$,然后再乘上排列数。

  于是上界可以卡的更小。

  $d$,$i$,$j$中两个数相等,排列数为3;三个数都相等,排列数为1;三个数都不等,排列数为6。

    $\large \begin{array}{ll} res &=& \sum \limits_{g=1}^{\sqrt{n}} \mu(g) \sum \limits_{d=1}^{\lfloor \sqrt[3]{\frac{n}{g^2}} \rfloor} \sum \limits_{i=d}^{\lfloor \sqrt{\frac{n}{dg^2}} \rfloor} \sum \limits_{j=i}^{\lfloor  \frac{n}{dig^2}\rfloor} [ijdg^2<=n] \\ &=& \sum \limits_{g=1}^{\sqrt{n}} \mu(g) \sum \limits_{d=1}^{\lfloor \sqrt[3]{\frac{n}{g^2}} \rfloor} \sum \limits_{i=d}^{\lfloor \sqrt{\frac{n}{dg^2}} \rfloor} (\lfloor \frac{n}{dig^2} \rfloor -i)*(3*[d==i]+6*[d!=i]) + ([d==i]+3*[d!=i])\end{array}$

  线性筛求莫比乌斯函数,然后枚举计算即可。

  时间复杂度约为$O(n^{\frac{2}{3}})$

Guess you like

Origin www.cnblogs.com/hz-Rockstar/p/11621308.html