「XXI Opencup GP of Tokyo」 Count Min Ratio


link。


非 GF 做法:https://xyix.gitee.io/posts/?&postname=cf-gym-102978-c


簡單轉化問題:求所有 \(x \in [1, \lfloor R / B\rfloor]\) 對應的合法方案數之和。

對於某一 \(x\),枚舉左邊的紅藍球數量,可得:

\[\begin{aligned} ans_x =& \sum_{b = 0}^{B}\sum_{r = bx}^{R - (B-b)x}\binom{r + b}{b}\binom{R - r + B - b}{B - b} \\ =& \sum_{b = 0}^{B}\sum_{d = 0}^{R - Bx}\binom{(bx + d) + b}{b}\binom{R - (bx + d) + B - b}{B - b} \\ =& \sum_{d = 0}^{R - Bx}\sum_{b = 0}^{B}\binom{(x + 1)b + d}{b}\binom{(x + 1)(B - b) + (R - Bx - d)}{B - b} \\ \end{aligned} \]

以下記 \(t = x + 1\)


系數 \(\binom{tb + d}{b}\)廣義二項級數 \(\mathcal B_t(z)\) 有關。

\(G(z) = \frac{z}{(1 + z)^t}\),則它的復合逆 \(F(z) = \mathcal B_t(z) - 1\)。於是:

\[\sum_{b=0}\binom{tb + d}{b}z^b = (1 + F)^d\times\frac{1 + F}{1 - (t - 1)F} \]

關於廣義二項級數的詳細內容可見文末。


代入原式,可得:

\[\begin{aligned} & \sum_{d = 0}^{R - Bx}\sum_{b = 0}^{B}\binom{tb + d}{b}\binom{t(B - b) + (R - Bx - d)}{B - b} \\ =& \sum_{d = 0}^{R - Bx}\sum_{b = 0}^{B}\left([z^b](1 + F)^d\times\frac{1 + F}{1 - (t - 1)F}\right)\left([z^{B-b}](1 + F)^{R - Bx - d}\times\frac{1 + F}{1 - (t - 1)F}\right) \\ =& [z^B]\sum_{d = 0}^{R - Bx}\left((1 + F)^d\times\frac{1 + F}{1 - (t - 1)F}\right)\left((1 + F)^{R - Bx - d}\times\frac{1 + F}{1 - (t - 1)F}\right) \\ =& (R - Bx + 1)\left([z^B](1 + F)^{R - Bx}\times\left(\frac{1 + F}{1 - (t - 1)F}\right)^2\right) \\ \end{aligned} \]

考慮對 \(H(F) = (1 + F)^{R - Bx}\times\left(\frac{1 + F}{1 - (t - 1)F}\right)^2\) 進行拉格朗日反演:

\[\begin{aligned}[] [z^B]H(F) =&[z^0]zH\times G'G^{-B-1} \\ =&[z^0]z(1 + z)^{R - Bx}\times\left(\frac{1 + z}{1 - (t - 1)z}\right)^2\times\frac{1 - (t - 1)z}{(1 + z)^{t + 1}}\times\left(\frac{(1 + z)^{(B + 1)t}}{z^{B + 1}}\right) \\ =&[z^B]\frac{(1 + z)^{(R - Bx) + 2 - (t + 1) + (B + 1)t}}{1 - (t - 1)z} \\ =&[z^B]\frac{(1 + z)^{R + B + 1}}{1 - xz} \\ =&\sum_{i = 0}^{B}\binom{R + B + 1}{i}x^{B - i} \end{aligned} \]

那么答案為 \((R + 1)\sum_{i = 0}^{B}\binom{R + B + 1}{i}\left(\sum_{x = 1}^{\lfloor R / B\rfloor}x^{B - i}\right) - B\sum_{i = 0}^{B}\binom{R + B + 1}{i}\left(\sum_{x = 1}^{\lfloor R / B\rfloor}x^{B - i + 1}\right)\)

多項式求逆算自然數冪和即可。


一些關於 \(\mathcal B_t(x)\) 的補充。

\(\mathcal B_t(x)\) 滿足方程 \(\mathcal B_t(x) = x\mathcal B^t_t(x) + 1\)。當 \(t = 2\) 時,\(\mathcal B_2(x)\) 即卡特蘭數的 OGF,那么 \(\mathcal B_t\) 其實是卡特蘭數的推廣。

參考卡特蘭數,這個方程至少有如下幾種組合意義:

(1)兒子有序的 \(t\) 叉樹。

按照定義,顯然有方程 \(\mathcal B_t(x) = x\mathcal B^t_t(x) + 1\)

(2)凸多邊形的 \(t + 1\) 邊形划分(好像去年 FJOI 考了這道題)。

選取一條凸多邊形上的邊,它所在的 \(t + 1\) 邊形將原凸多邊形划分成 \(t\) 份,因此有方程 \(\mathcal B_t(x) = x\mathcal B^t_t(x) + 1\)

(3)\((0, 0)\to(n, (t - 1)n)\) 且始終在直線 \(y = (t - 1)x\) 下方的路徑數。

仿照卡特蘭數,枚舉第一次碰到 \(y = (t - 1)x\) 的點,那么有 \(\mathcal B_t(x) = x\mathcal B_t(x)T(x) + 1\),其中 \(T(x)\) 表示完全不碰到 \(y = (t - 1)x\) 的方案數。

考慮這條路徑第一次碰到直線 \(y = (t - 1)x - i,i\in (0, t - 1)\) 的時刻(該路徑一定會碰到),並按這 \(t - 1\) 個時刻分段,每一段都貢獻一個 \(\mathcal B_t(x)\)。因此有 \(T(x) = \mathcal B_t^{t-1}(x)\)

感覺不是很平凡,如果有更好的構造請告訴我(用 Raney 引理直接得到封閉形式並驚訝發現它就是廣義二項級數之類的就算了)

這個組合意義可以用於解決本題。

p.s:

盡管上面探討了 \(\mathcal B_t\) 的組合意義,但是其實 \(t\) 在取任意值時下文中的公式都是成立的(此時定義為廣義二項系數)。

不過 \(\mathcal B_t\) 有常數項,不方便拉格朗日反演。記 \(F = \mathcal B_t - 1\),它有復合逆 \(G = x / (1 + x)^t\)。那么:

\[\begin{aligned}[] [x^n]\mathcal B_t^r =& [x^n](1 + F)^r \\ =& [x^0]x(1 + x)^r\frac{1-(t-1)x}{(1 + x)^{t + 1}}\frac{(1+x)^{tn+t}}{x^{n+1}} \\ =& [x^n](1 + x)^{tn+r-1}(1-(t-1)x) \\ =& \binom{tn + r - 1}{n} - \binom{tn + r - 1}{n - 1}(t - 1)\\ =& \binom{tn + r}{n}\times\frac{r}{tn + r} \end{aligned} \]

最后來推導 \(\sum_{n=0}\binom{tn + r}{n}x^n = (1 + F)^r\times\frac{1 + F}{1 - (t - 1)F}\)(當然,右推左是 trivial 的):

\[\begin{aligned} \binom{tn + r}{n} &= [x^n](1 + x)^{tn + r} \\ &= [x^0]\left(\frac{(1 + x)^t}{x}\right)^n(1 + x)^r \\ &= [x^0]G^{-n}(1 + F(G))^r \\ &= [x^0]x\times x^{-n}(1 + F)^r\times \frac{F'}{F} \\ &= [x^n](1 + F)^r \frac{xF'}{F} \end{aligned} \]

之后只需再證明 \(\frac{xF'}{F} = \frac{1 + F}{1 - (t - 1)F}\)

注意到 \(G' = \frac{1 - (t - 1)x}{(1 + x)^{t + 1}}\),那么有 \(\frac{xG'}{G} = \frac{1 - (t - 1)x}{1 + x}\)(這也表明 \(G\) 是微分有限的 廢話 它能不微分有限嗎),由鏈式法則求導又有 \(F' = \frac{1}{G'(F)}\)

於是 \(\frac{xF'}{F} = \frac{G(F)}{G'(F)F} = \frac{1 + F}{1 - (t - 1)F}\)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM