Du teach the inverse of the screen

Preface:

This method described below is not common, but it is very useful to
be exact, I have come to pioneer, so be sure to point out what is the problem

Pre-skills:

Multiplicative function
Dirichlet convolution
certain equation transforming ability

In fact, Du teach sieve knowledge aspect not very high

A brief introduction of several commonly used product functions:

\ (1. \ text {Euler function:} \ phi (x) = \ text {1-x with x the number of prime numbers} \)
\ (2. \ {text Mobius function:} \ mu (x) \ text {difficult to describe the function definition, can find themselves} \)
\ (3. \ {text divisor number:} D (X) = \ sum_ {D | X}. 1 \)
\ ( 4. \ text {divisors:} \ Sigma (X) = \ sum_ {D | D} X \)
\ (5. The \ text identity function {:} the I (X) =. 1 \)
\ (. 6. \ text {element functions: ID} (X) = X \)
\ (7. The \ text {membership function:} \ epsilon (x) = [x = 1] \)

Dirichlet convolution (*)

For two arithmetic functions \ (f (x), g
(x) \) thereof is convolutional: \ (F * G (X) = \ sum_ {D | X} F (D) \ Times G (\ frac {x} {d}) \)

Convolution satisfy
commutative: \ (F * G (X) = G * F (X) \)
associativity: \ ((F * G) * H (X) = F * (G * H) (X) \ )
distributive property: \ ((G + F) * H (X) = F * H (X) * G + H (X) \)

* And a multiplicative function multiplicative function is multiplicative function

Keep in mind the following formula:

\(d(x)=I*I(x)\)
\(\sigma(x)=I*id(x)\)
\(id(x)=I*\phi(x)\)
\(\epsilon(x)=I*\mu(x)\)
\(f*\epsilon(x)=f(x)\)

Into the title:

Du introduces teach sieve equation:

Du Du teach teach sieve sieve is the reason why, because there is a formula:

\[\sum_{i=1}^nf*g(i)=\sum_{i=1}^nf(i)\sum_{j=1}^{\lfloor\frac{n}{i}\rfloor}g(j)\]

prove:

\[\sum_{i=1}^nf*g(i)=\sum_{i=1}^n\sum_{d|i}f(\frac id)g(d)\]
\[=\sum_{i=1}^n\sum_{d=1}f(d)g(\frac id)[d|i]\]
\[=\sum_{d=1}^nf(d)\sum_{i=1}^{\lfloor\frac nd\rfloor}g(i)\]

Introduction:

Consider a question:

\[\sum_{i=1}^ni\sum_{j=1}^{\lfloor\frac{n}{i}\rfloor}\mu(j)\]

Common practice:
preprocessing \ (\ mu (x) \ ) prefix and then divides the block, time complexity \ (O (T \ sqrt n + n) \)

But if \ (T \ ^ LE10 7, the n-\ LE10 ^ 7 \) , properly properly TLE
concept Cha Du teach sieve formula, found

\[\sum_{i=1}^ni\sum_{j=1}^{\lfloor\frac{n}{i}\rfloor}\mu(j)=\sum_{i=1}^nid*\mu(i)=\sum_{i=1}^n\phi(i)\]

That this equation with \ (\ phi (x) \ ) prefix and the equivalent
then we only use pre-treatment \ (\ phi (x) \ ) prefix and, \ (O (1) \) to answer questions to , time complexity \ (O (T + n) \)

This is the most basic application of the inverse Du teach sieve

Advanced application 1:

Consider a question:

\[\sum_{i=1}^n\lfloor\frac ni\rfloor\mu*\phi(i)\]

Common practice:
multiplicative function sieve, the \ (\ mu * \ phi ( x) \ O (n \ log \ log n) \) , and determining the prefix and
for each query, the block is divisible
time complexity \ (O (n \ log \ log n + T \ sqrt n) \)

If the same \ (T \ Le ^ 10. 7, n-LE10. 7 ^ \ \) , properly properly TLE
case again Chadu concept taught sieve equation, if we \ (g (x) \) function into a special \ (the I (X) =. 1 \) , can be obtained

\[\sum_{i=1}^nI*f(i)=\sum_{i=1}^n\lfloor\frac{n}{i}\rfloor f(i)\]

The \ (f (x) \) replaced by \ (\ mu * \ phi ( x) \) is not that we demand equation right, then reduce to

\ [\ Sum_ {i = 1} ^ n \ lfloor \ frac ni \ rfloor \ mu * \ phi (i) = \ sum_ {i = 1} ^ Ni * \ mu * \ phi (i) = \ sum_ {i = 1} ^ n \ phi (i) \]

Then the rest is the same as the previous one, the time complexity \ (O (T + n) \)

Advanced Application 2:

Consider a question:

\[\sum_{i=1}^n\lfloor\frac ni\rfloor^2\mu(i)\]

Asian child seems very familiar. . .
Common practice:
Processing \ (\ mu (x) \ ) prefix and, divisible block, time complexity \ (O (n + T \ sqrt n) \)

Then \ (T \ le 10 ^ 7 , n \ le10 ^ 7 \) tumor data stuck

However, keep on watching Cha Du teach sieve equation, the \ (g (x) \) special function into \ (the above mentioned id (the X-) = the X-\) , you can get

\[\sum_{i=1}^nid*f(i)=\sum_{i=1}^nf(i)\sum_{j=1}^{\lfloor\frac{n}{i}\rfloor}id(j)\]
\[=\sum_{i=1}^nf(i)\frac{\lfloor\frac{n}{i}\rfloor\times(\lfloor\frac{n}{i}\rfloor+1)}{2}\]
\[=\frac{\sum_{i=1}^n\lfloor\frac{n}{i}\rfloor^2 f(i)+\sum_{i=1}^nI*f(i)}{2}\]

Transposition was

\[\sum_{i=1}^n\lfloor\frac{n}{i}\rfloor^2 f(i)=2\times\sum_{i=1}^nid*f(i)-\sum_{i=1}^nI*f(i)\]

The \ (f (x) \) is replaced with \ (\ MU (X) \) , to give

\[\sum_{i=1}^n\lfloor\frac{n}{i}\rfloor^2 \mu(i)=2\times\sum_{i=1}^n\phi(i)-1\]

Then the rest is the same as the previous two, the time complexity \ (O (T + n) \)

Of course, you want to do this I have no idea:

\[\sum_{i=1}^n\lfloor\frac ni\rfloor^2\mu(i)=\sum_{i=1}^n\sum_{j=1}^n[gcd(i,j)=1]=2\times\sum_{i=1}^n\phi(i)-1\]

to sum up:

All in all, three of the more important formulas

\[1.\sum_{i=1}^nf*g(i)=\sum_{i=1}^nf(i)\sum_{j=1}^{\lfloor\frac{n}{i}\rfloor}g(j)\]

\[2.\sum_{i=1}^nI*f(i)=\sum_{i=1}^n\lfloor\frac{n}{i}\rfloor f(i)\]

\[3.\sum_{i=1}^n\lfloor\frac{n}{i}\rfloor^2 f(i)=2\times\sum_{i=1}^nid*f(i)-\sum_{i=1}^nI*f(i)\]

postscript:

You can look at this solution to a problem, this method should have a better understanding

Because the network temporarily not find such a method, it is above all yy bloggers out
there please be useful by themselves weigh wood, be sure to point out an error
on this new development methods are also sure to raise

Guess you like

Origin www.cnblogs.com/MYsBlogs/p/11445713.html