Merlot Valley P1587 [NOI2016] cycle of

Immortal title

Given \ (n-, m \) , find a complementary value equal to how much can be expressed as \ (\ frac {x} { y} \) a number satisfying \ (1≤x≤n, 1≤y≤m \) , and \ (\ frac {x} { y} \) in \ () K \ the decimals binary pure (in particular, is an integer of pure decimals)
\ (1 ≦ n, ^. 9 m≤10 , 2≤k≤2000 \)

First requires complementary equal in value, i.e. requires \ (x⊥y \)

But also to meet pure decimals, assuming the cycle length of the section \ (L \) , then the \ (\ frac {k ^ lx } {y} - \ lfloor \ frac {k ^ lx} {y} \ rfloor = \ frac { x} {y} - \ lfloor \ frac {x} {y} \ rfloor \)

The same on both sides by a \ (Y \) to give \ (k ^ lx- \ lfloor \ frac {k ^ lx} {y} \ rfloor y = x- \ lfloor \ frac {x} {y} \ rfloor y \)

Under the effect of membrane \ (k ^ lx≡x mod y \ )

And because \ (x⊥y \) , so \ (k ^ l≡1 mod y \ )

At this point we assume \ (GCD (K, Y) = D \) , then the \ (k = k_1d, y = k_2d \)

\ (^ LD k_1 l≡1 ^ v y \)

So \ (k_2d | (k_1 ^ ld ^ l-1) \)

And because \ (k_1⊥k_2 \) , so \ (d | (k_1 ^ ld ^ l-1) \)

At this time, the right side is equal DESCRIPTION \ (k_3d \) , derived \ (1 \) a \ (D \) multiple

So \ (y⊥k \)

Becomes a problem, find
\ [\ sum \ limits_ {i
= 1} ^ {n} \ sum \ limits_ {j = 1} ^ {m} [i⊥j] [j⊥k] \] This \ (I ⊥j \) be apparent inversion
\ [\ sum \ limits_ {j = 1} ^ {n} [j⊥k] \ sum \ limits_ {i = 1} ^ {m} sum \ limits_ {d \ | i, d | j} \ mu (d
) \] we enumerate becomes \ (D \)
\ [\ SUM \ limits_. 1} = {D n-^ {} \ MU (D) \ SUM \ limits_ {D | I} \ sum \ limits_ {d | j
} [gcd (j, k) == 1] \] we \ (d \) up to, but remember \ (d \) also, and \ (k \) are relatively prime
\ [\ sum \ limits_ {d = 1} ^ {n} [gcd (d, k) == 1] \ mu (d) \ sum \ limits_ {i = 1} ^ {\ lfloor \ frac {n} {d } \} rfloor \ SUM \ limits_. 1} = {J ^ {\ lfloor \ FRAC {D {m}} \} rfloor [GCD (J, K) ==. 1] \]
\ (I \) useless, Simplification off
\ [\ sum \ limits_ {d = 1} ^ {n} [gcd (d, k) == 1] \ mu (d) \ lfloor \ frac {n} {d} \ rfloor \ sum \ limits_ {j = 1} ^ {\
lfloor \ frac {m} {d} \ rfloor} [gcd (j, k) == 1] \] In this case we set\ (S (n, k) = \ sum \ limits_ {i = 1} ^ {n} \ mu (i) [gcd (i, k) == 1], f (n) = \ sum \ limits_ {i . 1} ^ {n-=} [GCD (I, K) ==. 1] \)
\ [\ SUM \ limits_. 1} = {D n-^ {} [GCD (D, K) ==. 1] \ MU (D ) \ lfloor \ frac {n}
{d} \ rfloor f (\ lfloor \ frac {m} {d} \ rfloor) \] A quick calculated at a particular point \ (S (n) \) and \ (f (n ) \) values, the block division can be

Consider first \ (f (n) \) how demand

Because of \ (GCD (I, K) == GCD (I + K, K) \) , so \ (f (n) = f (k) * \ lfloor \ frac {n} {k} \ rfloor + f ( n \% k) \) preconditioning the \ (n≤k \) of f (n) can be \ (O (1) \) is calculated

Then \ (S (n-, K) \) , which is equal to \ (\ sum \ limits_ {i = 1} ^ {n} \ mu (i) [gcd (i, k) == 1] \)

Inversion at \ (S (n, k) = \ sum \ limits_ {i = 1} ^ {n} \ mu (i) \ sum \ limits_ {d | i, d | k} \ mu (d) \)

Priority enumeration \ (D \) , to give \ (S (n, k) = \ sum \ limits_ {d | k} \ mu (d) \ sum \ limits_ {d | i} \ mu (i) \)

The later to enumerate multiple \ (S (n, k) = \ sum \ limits_ {d | k} \ mu (d) \ sum \ limits_ {i = 1} ^ {\ lfloor \ frac {n} {d } \ rfloor} \ mu (id ) \)

The nature of Mobius function, if and only if \ (i⊥d \) when \ (\ mu (id) \ ) is not \ (0 \) , so \ (S (n, k) = \ sum \ limits_ {d | k} \ mu (d) ^ 2 \ sum \ limits_ {i = 1} ^ {\ lfloor \ frac {n} {d} \ rfloor} \ mu (i) [i⊥d] \)

This latter fact was found \ (S (\ lfloor \ {n-FRAC} {D} \ rfloor, D) \) , then it can be solved recursively

But recursion boundary (d = 1 \) \ how to do it

\ (S (n, 1) = \ sum \ limits_ {i = 1} ^ {n} \ mu (i) [gcd (i, 1) == 1] = \ sum \ limits_ {i = 1} ^ { } the n-\ MU (i) \) , the screen is not that Du teach you!

Then
\ [\ sum \ limits_ {d = 1} ^ {n} [gcd (d, k) == 1] \ mu (d) \ lfloor \ frac {n} {d} \ rfloor f (\ lfloor \ frac {m} {d} \ rfloor
) \] can be solved divider block

However, I found a more gods to beg \ (S (n, k) \) method!

\(g(n)=[gcd(n,k)==1],S(n)=\sum\limits_{i=1}^{n}\mu(i)g(i)\)

那么\(\sum\limits_{i=1}^{n}g(i)*S(\lfloor\frac{n}{i}\rfloor)=\sum\limits_{i=1}^{n} \sum\limits_{j=1}^{\lfloor\frac{n}{i}\rfloor}g(i)\mu(j)g(j)\)
\(d=i*j\)
\(=\sum\limits_{d=1}^{n}\sum\limits_{i|d}g(i)*\mu(\lfloor\frac{d}{i}\rfloor)*g(\frac{d}{i})\)

Because of \ (G \) is completely multiplicative function, so \ (= \ sum \ limits_ { d = 1} ^ {n} \ sum \ limits_ {i | d} * \ mu (\ lfloor \ frac {d} { i} \ rfloor) * g ( d) \)

And because \ (\ *. 1 MU = E \) , so \ (= g (1) = 1 \)

所以\(S(n)=1-\sum\limits_{i=2}^{n}g(i)*S(\lfloor\frac{n}{i}\rfloor)\)

We found \ (\ sum \ limits_ {i = 1} ^ {n} \) is \ (F (n-) \) , it is possible to directly teach Du screen!

Guess you like

Origin www.cnblogs.com/knife-rose/p/12024490.html
Recommended