2020 ICPC 济南 F. Gcd Product
Gcd Product
Cm=∑i=1mAgcd?(i,m)Bgcd?(k+1?i,m)∑d1∣mAd1∑d2∣mBd2∑i=1m([gcd?(id1,md1)=1][d1∣i])([gcd?(m+1?id2,md2)=1][d2∣m+1?i])∑d1∣mAd1∑d2∣mBd2∑k1∣md1μ(k1)∑k2∣md2μ(k2)∑i=1m([d1∣i][k1∣id1])([d2∣m+1?i][k2∣m+1?id2])T1=d1×k1,T2=d2×k2∑T1∣m∑d1∣T1Ad1μ(T1d1)∑T2∣m∑d2∣T2Bd2μ(T2d2)∑i=1m[T1∣i][T2∣m+1?i]C_m = \sum_{i = 1} ^{m} A_{\gcd(i, m)} B_{\gcd(k + 1 - i, m)}\\ \sum_{d1 \mid m} A_{d1} \sum_{d_2 \mid m}B_{d_2} \sum_{i = 1} ^{m}\left([\gcd(\frac{i}{d_1}, \frac{m}{d_1}) = 1][d_1 \mid i]\right)\left([\gcd(\frac{m + 1 - i}{d_2}, \frac{m}{d_2}) = 1][d_2 \mid m + 1 - i]\right)\\ \sum_{d_1 \mid m} A_{d_1} \sum_{d_2 \mid m} B_{d_2} \sum_{k_1 \mid \frac{m}{d_1}} \mu(k_1) \sum_{k_2 \mid \frac{m}{d_2}} \mu(k_2) \sum_{i = 1} ^{m} \left([d_1 \mid i][k_1 \mid \frac{i}{d_1}] \right)\left([d_2 \mid m + 1 - i][k_2 \mid \frac{m + 1 - i}{d_2}] \right)\\ T_1 = d_1 \times k_1, T_2 = d_2 \times k_2\\ \sum_{T_1 \mid m} \sum_{d_1 \mid T_1} A_{d_1} \mu(\frac{T_1}{d_1}) \sum_{T_2 \mid m} \sum_{d_2 \mid T_2} B_{d_2} \mu(\frac{T_2}{d_2}) \sum_{i = 1} ^{m} [T_1 \mid i][T_2 \mid m + 1 - i]\\ Cm?=i=1∑m?Agcd(i,m)?Bgcd(k+1?i,m)?d1∣m∑?Ad1?d2?∣m∑?Bd2??i=1∑m?([gcd(d1?i?,d1?m?)=1][d1?∣i])([gcd(d2?m+1?i?,d2?m?)=1][d2?∣m+1?i])d1?∣m∑?Ad1??d2?∣m∑?Bd2??k1?∣d1?m?∑?μ(k1?)k2?∣d2?m?∑?μ(k2?)i=1∑m?([d1?∣i][k1?∣d1?i?])([d2?∣m+1?i][k2?∣d2?m+1?i?])T1?=d1?×k1?,T2?=d2?×k2?T1?∣m∑?d1?∣T1?∑?Ad1??μ(d1?T1??)T2?∣m∑?d2?∣T2?∑?Bd2??μ(d2?T2??)i=1∑m?[T1?∣i][T2?∣m+1?i]
觀察式子,不難發現∑d1∣T1Ad1μ(T1d1),∑d2∣T2Bd2μ(T2d2)\sum\limits_{d_1 \mid T_1} A_{d_1} \mu(\frac{T_1}{d_1}), \sum_{d_2 \mid T_2} B_{d_2} \mu(\frac{T_2}{d_2})d1?∣T1?∑?Ad1??μ(d1?T1??),∑d2?∣T2??Bd2??μ(d2?T2??),二者對于給定的T1,T2T_1,T_2T1?,T2?都是可以確定的,跟變量mmm無關,
設f(n)=∑d∣nAdμ(nd),g(n)=∑d∣nBdμ(nd)f(n) = \sum\limits_{d \mid n} A_ze8trgl8bvbq \mu(\frac{n}ze8trgl8bvbq), g(n) = \sum_{d \mid n} B_ze8trgl8bvbq \mu(\frac{n}ze8trgl8bvbq)f(n)=d∣n∑?Ad?μ(dn?),g(n)=∑d∣n?Bd?μ(dn?),得到∑T1∣mf(T1)∑T2∣mg(T2)∑i=1m[T1∣i][T2∣m+1?i]\sum\limits_{T_1 \mid m} f(T_1) \sum\limits_{T_2 \mid m} g(T_2) \sum\limits_{i = 1} ^{m}[T_1 \mid i][T_2 \mid m + 1 - i]T1?∣m∑?f(T1?)T2?∣m∑?g(T2?)i=1∑m?[T1?∣i][T2?∣m+1?i],
接下來我們考慮化簡∑i=1m[T1∣i][T2∣m+1?i]\sum\limits_{i = 1} ^{m} [T_1 \mid i][T_2 \mid m + 1 - i]i=1∑m?[T1?∣i][T2?∣m+1?i]。
設i=T1k1,m+1?i=T2k2設i = T_1 k_1, m + 1 - i = T_2 k_2設i=T1?k1?,m+1?i=T2?k2?,則T1k1+T2k2=m+1T_1 k_1 + T_2 k_2 = m + 1T1?k1?+T2?k2?=m+1,可得:
同余方程T1k1≡1(modT2),T2k2≡1(modT1)T_1 k_1 \equiv 1 \pmod{T_2}, T_2 k_2 \equiv 1 \pmod{T_1}T1?k1?≡1(modT2?),T2?k2?≡1(modT1?)。
由T1∣i,T2∣m+1?iT_1 \mid i, T_2 \mid m + 1 - iT1?∣i,T2?∣m+1?i,則gcd?(T1,T2)∣i,gcd?(T1,T2)∣m+1?i\gcd(T_1, T_2) \mid i, \gcd(T_1, T_2) \mid m + 1 - igcd(T1?,T2?)∣i,gcd(T1?,T2?)∣m+1?i,所以gcd?(T1,T2)∣m+1\gcd(T_1, T_2) \mid m + 1gcd(T1?,T2?)∣m+1。
由T1∣m,T2∣mT_1 \mid m, T_2 \mid mT1?∣m,T2?∣m,則gcd?(T1,T2)∣m\gcd(T_1, T_2) \mid mgcd(T1?,T2?)∣m,因為gcd(m,m+1)=1gcd(m, m + 1) = 1gcd(m,m+1)=1,所以有gcd(T1,T2)=1gcd(T_1, T_2) = 1gcd(T1?,T2?)=1。
所以k1,k2k_1, k_2k1?,k2?,分別在膜T2,T1T_2, T_1T2?,T1?下有且只有唯一解x1,x2x_1, x_2x1?,x2?,有x1T1<T1T2,x2T2<T1T2x_1 T_1 < T_1 T_2, x_2 T_2 < T_1 T_2x1?T1?<T1?T2?,x2?T2?<T1?T2?,
可得x1T1+x2T2=T1T2+1x_1T_1 + x_2 T_2 = T_1T_2 + 1x1?T1?+x2?T2?=T1?T2?+1,要使k1T1+k2T2=m+1k_1T_1 + k_2 T_2 = m + 1k1?T1?+k2?T2?=m+1,
相當于在x1T1+x2T2=T1T2+1x_1T_1 + x_2 T_2 = T_1T_2 + 1x1?T1?+x2?T2?=T1?T2?+1的基礎上給x1T1,x2T2x_1T_1,x_2T_2x1?T1?,x2?T2?組合分配,湊得m?T1T2m - T_1 T_2m?T1?T2?。
設m=KT1T2m = KT_1T_2m=KT1?T2?,所以解的個數就是K=mT1T2K = \frac{m}{T_1T_2}K=T1?T2?m?,則有:
Cm=∑T1∣mf(T1)∑T2∣mg(T2)mT1T2[gcd?(T1,T2)=1]T=T1T2∑T∣mmT∑T1∣Tf(T1)g(TT1)[gcd(T1,TT2)=1]C_m = \sum_{T_1 \mid m} f(T_1) \sum_{T_2 \mid m} g(T_2) \frac{m}{T_1T_2}[\gcd(T_1, T_2) = 1]\\ T = T_1 T_2\\ \sum_{T \mid m} \frac{m}{T} \sum_{T_1 \mid T} f(T_1) g(\frac{T}{T_1})[gcd(T_1, \frac{T}{T_2}) = 1]\\ Cm?=T1?∣m∑?f(T1?)T2?∣m∑?g(T2?)T1?T2?m?[gcd(T1?,T2?)=1]T=T1?T2?T∣m∑?Tm?T1?∣T∑?f(T1?)g(T1?T?)[gcd(T1?,T2?T?)=1]
先做一次迪利克雷卷積得到f,gf, gf,g,再做一次互質迪利克雷卷積得到∑T1∣Tf(T1)g(TT1)[gcd(T1,TT2)=1]\sum\limits_{T_1 \mid T} f(T_1) g(\frac{T}{T_1})[gcd(T_1, \frac{T}{T_2}) = 1]T1?∣T∑?f(T1?)g(T1?T?)[gcd(T1?,T2?T?)=1],最后迪利克雷卷積得到答案。
總結
以上是生活随笔為你收集整理的2020 ICPC 济南 F. Gcd Product的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 平遥医保备案报销电话号码(平遥医保备案)
- 下一篇: 阿里云域名怎么转让(阿里云域名怎么转让给