当前位置:网站首页>[hdu6868] absolute math (pusher + Mobius inversion)
[hdu6868] absolute math (pusher + Mobius inversion)
2022-04-23 09:43:00 【Zimba_】
The question :
Make f ( n ) = ∑ d ∣ n ∣ μ ( d ) ∣ f(n)=\sum_{d|n}|\mu (d)| f(n)=∑d∣n∣μ(d)∣. T T T Group inquiry , Each group is given one n n n and m m m, seek ∑ i = 1 m f ( n i ) \sum_{i=1}^{m}f(ni) ∑i=1mf(ni).
( 1 ≤ T ≤ 1 0 4 , 1 ≤ n , m ≤ 1 0 7 ) (1\leq T\leq 10^{4},1\leq n,m\leq 10^{7}) (1≤T≤104,1≤n,m≤107)
deduction :
First, according to the Mobius function μ ( n ) \mu (n) μ(n) The definition of can be known , When n n n When there is a square factor , ∣ μ ( n ) ∣ = 0 |\mu (n)|=0 ∣μ(n)∣=0, otherwise ∣ μ ( n ) ∣ = 1 |\mu (n)|=1 ∣μ(n)∣=1.
therefore f ( n ) f(n) f(n) It means n n n Of the factors , Number of factors without square factor .
We will n n n Find out all the qualitative factors , Because there can't be a square factor , So the number of times of each prime factor is either 0 0 0, Either for 1 1 1. Got it. f ( n ) = 2 w ( n ) f(n)=2^{w(n)} f(n)=2w(n), among w ( n ) w(n) w(n) Express n n n How many different qualitative factors .
According to the above formula , You can find f ( a b ) = f ( a ) f ( b ) f ( g c d ( a , b ) ) = 2 w ( a ) + w ( b ) − w ( g c d ( a , b ) ) f(ab)=\frac{f(a)f(b)}{f(gcd(a,b))}=2^{w(a)+w(b)-w(gcd(a,b))} f(ab)=f(gcd(a,b))f(a)f(b)=2w(a)+w(b)−w(gcd(a,b)).
It's out g c d gcd gcd after , We consider Mobius inversion , We need to put g c d gcd gcd Bring up , The original formula becomes .
∑ i = 1 m f ( n i ) = ∑ g = 1 m i n ( n , m ) 2 − w ( g ) ∑ i = 1 m 2 w ( n ) + w ( i ) [ g = g c d ( n , i ) ] \sum_{i=1}^{m}f(ni)=\sum_{g=1}^{min(n,m)}2^{-w(g)}\sum_{i=1}^{m}2^{w(n)+w(i)}[g=gcd(n,i)] i=1∑mf(ni)=g=1∑min(n,m)2−w(g)i=1∑m2w(n)+w(i)[g=gcd(n,i)]
Now start Mobius inversion , Make y ( g ) = ∑ i = 1 m 2 w ( n ) + w ( i ) [ g = g c d ( n , i ) ] y(g)=\sum_{i=1}^{m}2^{w(n)+w(i)}[g=gcd(n,i)] y(g)=∑i=1m2w(n)+w(i)[g=gcd(n,i)].
Then make Y ( d ) = ∑ d ∣ g y ( g ) Y(d)=\sum_{d|g}y(g) Y(d)=∑d∣gy(g), namely ,
Y ( d ) = ∑ d ∣ g ∑ i = 1 m 2 w ( n ) + w ( i ) [ g = g c d ( n , i ) ] = ∑ i = 1 m ∑ d ∣ n ∑ d ∣ i 2 w ( n ) + w ( i ) Y(d)=\sum_{d|g}\sum_{i=1}^{m}2^{w(n)+w(i)}[g=gcd(n,i)]=\sum_{i=1}^{m}\sum_{d|n}\sum_{d|i}2^{w(n)+w(i)} Y(d)=d∣g∑i=1∑m2w(n)+w(i)[g=gcd(n,i)]=i=1∑md∣n∑d∣i∑2w(n)+w(i)
Then there are y ( g ) = ∑ g ∣ d μ ( d / g ) Y ( d ) y(g)=\sum_{g|d}\mu (d/g)Y(d) y(g)=∑g∣dμ(d/g)Y(d).
The original formula becomes ,
∑ g = 1 m i n ( n , m ) y ( g ) = ∑ g = 1 m i n ( n , m ) 2 − w ( g ) ∑ g ∣ d μ ( d / g ) ∑ d ∣ n ∑ i = 1 m ∑ d ∣ i 2 w ( n ) + w ( i ) = 2 w ( n ) ∑ i = 1 m 2 w ( i ) ∑ d ∣ n ∑ d ∣ i ∑ g ∣ d 2 − w ( g ) μ ( d / g ) \sum_{g=1}^{min(n,m)}y(g)=\sum_{g=1}^{min(n,m)}2^{-w(g)}\sum_{g|d}\mu(d/g)\sum_{d|n}\sum_{i=1}^{m}\sum_{d|i}2^{w(n)+w(i)}=2^{w(n)}\sum_{i=1}^{m}2^{w(i)}\sum_{d|n}\sum_{d|i}\sum_{g|d}2^{-w(g)}\mu(d/g) g=1∑min(n,m)y(g)=g=1∑min(n,m)2−w(g)g∣d∑μ(d/g)d∣n∑i=1∑md∣i∑2w(n)+w(i)=2w(n)i=1∑m2w(i)d∣n∑d∣i∑g∣d∑2−w(g)μ(d/g)
We make G ( d ) = ∑ g ∣ d 2 − w ( g ) μ ( d / g ) G(d)=\sum_{g|d}2^{-w(g)}\mu(d/g) G(d)=∑g∣d2−w(g)μ(d/g), Sure o ( n l o g n ) o(nlogn) o(nlogn) Preprocess this function , Then turn the formula .
A N S = 2 w ( n ) ∑ i = 1 m 2 w ( i ) ∑ d ∣ n ∑ d ∣ i G ( d ) = 2 w ( n ) ∑ d ∣ n G ( d ) ∑ i = 1 m ∑ d ∣ i 2 w ( i ) = 2 w ( n ) ∑ d ∣ n G ( d ) ∑ i = 1 ⌊ m d ⌋ 2 w ( i d ) ANS=2^{w(n)}\sum_{i=1}^{m}2^{w(i)}\sum_{d|n}\sum_{d|i}G(d)=2^{w(n)}\sum_{d|n}G(d)\sum_{i=1}^{m}\sum_{d|i}2^{w(i)}=2^{w(n)}\sum_{d|n}G(d)\sum_{i=1}^{\lfloor \frac{m}{d} \rfloor}2^{w(id)} ANS=2w(n)i=1∑m2w(i)d∣n∑d∣i∑G(d)=2w(n)d∣n∑G(d)i=1∑md∣i∑2w(i)=2w(n)d∣n∑G(d)i=1∑⌊dm⌋2w(id)
Code :
Insert a code chip here
版权声明
本文为[Zimba_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230621425148.html
边栏推荐
- Kettle实验
- Go language learning notes - language interface | go language from scratch
- Setnx command execution failed due to full redis memory
- Redis exception read error on connection solution
- Practice of Flink streaming batch integration in Xiaomi
- SAP ECC connecting SAP pi system configuration
- Kettle实验 转换案例
- SAP 101K 411k inventory change
- Easy to understand subset DP
- Machine learning (VI) -- Bayesian classifier
猜你喜欢

Kernel PWN learning (4) -- double fetch & 0ctf2018 baby

How to obtain geographical location based on photos and how to prevent photos from leaking geographical location

Simple understanding of arguments in JS

如何实现根据照片获取地理位置及如何防御照片泄漏地理位置

Kettle实验
![3、 6 [Verilog HDL] gate level modeling of basic knowledge](/img/36/46f2413ecb12f81c003848c93f6bc9.jpg)
3、 6 [Verilog HDL] gate level modeling of basic knowledge

Leetcode0587. 安装栅栏(difficult)

JS DOM event

MySQL of database -- Fundamentals

Where is int a = 1 stored
随机推荐
Operation not allowed for a result set of type resultset TYPE_ FORWARD_ ONLY. Explain in detail
Redis 过期 key 清理删除策略汇总
DMP engine work summary (2021, lightsaber)
如何实现根据照片获取地理位置及如何防御照片泄漏地理位置
ABAP 7.4 SQL Window Expression
501. Mode in binary search tree
kernel-pwn学习(4)--Double Fetch&&0CTF2018-baby
Set the maximum width of the body, but why does the background color of the body cover the whole page?
nn. Explanation of module class
Pre parsing of JS
Machine learning (VI) -- Bayesian classifier
AI上推荐 之 MMOE(多任务yyds)
Leetcode题库78. 子集(递归 c实现)
JS DOM learn three ways to create elements
NPM installation yarn
三、6【Verilog HDL】基础知识之门级建模
MacOS下使用CLion编译调试MySQL8.x
What is monitoring intelligent playback and how to use intelligent playback to query video recording
SAP salv14 background output salv data can directly save files and send emails (with sorting, hyperlink and filtering format)
《数字电子技术基础》3.1 门电路概述、3.2 半导体二极管门电路