zoukankan      html  css  js  c++  java
  • Codeforces 1477F. Nezzar and Chocolate Bars

    好题!

    题意:你有一条长为(L)的线段,初始时线段上已经有(n-1)个分割点将其划分为(n)段,其中第(i)段长为(l_i)。每次在([0,L])中随机一个实数(r),在线段上加入坐标为(r)的分割点,直到所有分割点将线段分割为每段长度不超过(K)的若干段。求新加入的分割点个数的期望。模(998244353)

    (nleq 50,L,Kleq 2000)

    题解:

    令生成函数(f)对应的指数生成函数为( ilde f)

    首先考虑(n=1)的情况。假设第(i)步及以内能够结束的概率为(p_i),那么答案为(sum_{igeq 0}(1-p_i))。考虑如何计算(p_i)

    显然,第(n)步及以内可以结束等价于无论是否达到要求强行做到第(n)步,此时符合要求。考虑每一步的随机都是独立的,那么随机生成的坐标点列((z_1,z_2,dots,z_n))是均匀分布在(Omega_L={(z_1,z_2,dots,z_n)|0leq z_ileq L,i=1,2,dots,n})中的,每一个特定的坐标点列((z_1,z_2,dots,z_n))被生成的概率元为:

    [frac{mathrm{d}z}{idotsint_{Omega_L}mathrm{d}z}=frac{mathrm{d}z}{L^n} ]

    但从((z_1,z_2,dots,z_n))中无法很好地分析是否满足(leq K)的要求,考虑对该空间进行转化。在(Omega_L)中的点坐标几乎都是两两不同的,将其排序,转化为((hat z_1,hat z_2,dots,hat z_n)),其中(0leq hat z_1leq hat z_2leq cdotsleq hat z_nleq L),令(hat Omega_L={(hat z_1,hat z_2,dots,hat z_n)|0leq hat z_1leq hat z_2leq cdotsleq hat z_nleq L}),则(hat Omega_L)中的每个点几乎都对应(n!)(Omega_L)中的点,于是每个(hatOmega_L)中的点的概率元为(frac{n!mathrm{d}z}{L^n})

    为了判断是否满足要求,进一步将((hat z_1,hat z_2,dots,hat z_n))唯一对应到其差分数组((hat z_1,hat z_2-hat z_1,dots,hat z_n-hat z_{n-1})),均匀分布在空间( ilde Omega_L={( ilde z_1, ilde z_2,dots, ilde z_n)| ilde z_igeq 0,sum_{i=1}^n ilde z_ileq L})中,每个点的概率元仍然为(frac{n!mathrm{d}z}{L^n})。顺便说明,这证明了(idotsint_{ ilde Omega_L}mathrm{d}z=frac{L^n}{n!})

    于是在( ilde Omega_L)中,(( ilde z_1, ilde z_2,dots, ilde z_n))符合要求等价于(0leq ilde z_ileq K,i=1,2,dots,n)(0leq L-sum_{i=1}^nz_ileq K),于是我们有符合要求的概率等于(Omega_Kcap( ilde Omega_Lsetminus ilde Omega_{L-K}))中的点的概率元的和,即:

    [p_n=idotsint_{Omega_Kcap( ilde Omega_Lsetminus ilde Omega_{L-K})}frac{n!mathrm{d}z}{L^n}=frac{n!}{L^n}Bigg(idotsint_{Omega_Kcap ilde Omega_L}mathrm{d}z-idotsint_{Omega_Kcap ilde Omega_{L-K}}mathrm{d}zBigg) ]

    现在关注如何求出(idotsint_{Omega_Acap ilde Omega_B}mathrm{d}z),定义可重集(Phi_{A,S}={(z_1,z_2,dots,z_n)|z_igeq A,iin S,z_igeq 0,i otin S})

    容斥(Omega_A)(z_tleq A)的限制,就可以将(Omega_A)几乎完全地用若干个(Phi_{A,S})表示出来(除若干边界上的点以外):

    [Omega_A=sum_{Ssubseteq{1,2,dots,n}}(-1)^{|S|}Phi_{A,S} ]

    于是:

    [idotsint_{Omega_Acap ilde Omega_B}mathrm{d}z=sum_{Ssubseteq{1,2,dots,n}}(-1)^{|S|}idotsint_{Phi_{A,S}cap ilde Omega_B}mathrm{d}z ]

    而对于(Phi_{A,S}cap ilde Omega_B)中的点((z_1,z_2,dots,z_n)),可以将满足(iin S)(z_i)减去(A),从而与( ilde Omega_{B-|S|A})中的点一一对应,于是(Phi_{A,S}cap ilde Omega_B)( ilde Omega_{B-|S|A})的积分相等,由前文证明的结论可以得到:

    [idotsint_{Omega_Acap ilde Omega_B}mathrm{d}z=sum_{Ssubseteq{1,2,dots,n}}(-1)^{|S|}idotsint_{ ilde Omega_{B-|S|A}}mathrm{d}z ]

    [=sum_{i=0}^n(-1)^{i}{nchoose i}idotsint_{ ilde Omega_{B-iA}}mathrm{d}z=sum_{i=0}^{lfloorfrac{B}{A} floor}(-1)^i{nchoose i}frac{(B-iA)^n}{n!} ]

    回代到(p_n)的表达式中,可以得到:

    [p_n=frac{n!}{L^n}Bigg(sum_{i=0}^{lfloorfrac{L}{K} floor}(-1)^i{nchoose i}frac{(L-iK)^n}{n!}-sum_{i=0}^{lfloorfrac{L}{K} floor-1}(-1)^i{nchoose i}frac{(L-(i+1)K)^n}{n!}Bigg) ]

    [=sum_{i=0}^{lfloorfrac{L}{K} floor}(-1)^i{nchoose i}Big(1-ifrac{K}{L}Big)^n+sum_{i=1}^{lfloorfrac{L}{K} floor}(-1)^i{nchoose i-1}Big(1-ifrac{K}{L}Big)^n ]

    [=1+sum_{i=1}^{lfloorfrac{L}{K} floor}(-1)^i{n+1choose i}Big(1-ifrac{K}{L}Big)^n ]

    于是没有初始分割点的答案就为(sum_{igeq 0}sum_{j=1}^{lfloorfrac{L}{K} floor}(-1)^{j+1}{i+1choose j}Big(1-jfrac{K}{L}Big)^i),下面考虑存在初始分割点的情况。

    定义(q_{i,j}=1+sum_{k=1}^{lfloorfrac{l_i}{K} floor}(-1)^k{j+1choose k}Big(1-kfrac{K}{l_i}Big)^j)(Q_i=sum_{kgeq 0}q_{i,k}Big(frac{l_i}{L}Big)^kx^k)(p_i)仍然如上定义,(P=sum_{kgeq 0}p_kx^k),则此时(p_i)的值为:

    [p_i=sum_{k_1+k_2+dots+k_n=i}{ichoose k_1,k_2,dots,k_n}prod_{j=1}^nBig(frac{l_j}{L}Big)^{k_j}q_{j,k_j} ]

    [frac{p_i}{i!}=sum_{k_1+k_2+dots+k_n=i}prod_{j=1}^nfrac{Big(frac{l_j}{L}Big)^{k_j}q_{j,k_j}}{k_j!} ]

    即:

    [ ilde P=prod_{i=1}^n ilde Q_i ]

    我们要求的答案是(sum_{kgeq 0}(1-k![x^k] ilde P)=sum_{kgeq 0}k![x^k](e^x- ilde P)),那么首先考虑( ilde Q_i)的表达式:

    [ ilde Q_i=sum_{jgeq 0}frac{1}{j!}Bigg(1+sum_{k=1}^{lfloorfrac{l_i}{K} floor}(-1)^k{j+1choose k}Big(1-kfrac{K}{l_i}Big)^jBigg)Big(frac{l_i}{L}Big)^jx^j ]

    [=sum_{jgeq 0}frac{1}{j!}Big(frac{l_i}{L}Big)^jx^j+sum_{jgeq 0}frac{1}{j!}sum_{k=1}^{lfloorfrac{l_i}{K} floor}(-1)^k{j+1choose k}Big(frac{l_i-kK}{L}Big)^jx^j ]

    [=e^{frac{l_i}{L}x}+sum_{jgeq 0}sum_{k=1}^{min{j+1,lfloorfrac{l_i}{K} floor}}(-1)^kfrac{j+1}{k!(j+1-k)!}Big(frac{l_i-kK}{L}Big)^jx^j ]

    [=e^{frac{l_i}{L}x}+sum_{jgeq 0}sum_{k=1}^{min{j+1,lfloorfrac{l_i}{K} floor}}(-1)^kfrac{j+1-k+k}{k!(j+1-k)!}Big(frac{l_i-kK}{L}Big)^jx^j ]

    [=e^{frac{l_i}{L}x}+sum_{jgeq 0}sum_{k=1}^{min{j,lfloorfrac{l_i}{K} floor}}(-1)^kfrac{1}{k!(j-k)!}Big(frac{l_i-kK}{L}Big)^jx^j+sum_{jgeq 0}sum_{k=1}^{min{j+1,lfloorfrac{l_i}{K} floor}}(-1)^kfrac{1}{(k-1)!(j+1-k)!}Big(frac{l_i-kK}{L}Big)^jx^j ]

    [=e^{frac{l_i}{L}x}+sum_{k=1}^{lfloorfrac{l_i}{K} floor}frac{(-1)^k}{k!}sum_{jgeq k}frac{Big(frac{l_i-kK}{L}Big)^j}{(j-k)!}x^j+sum_{k=1}^{lfloorfrac{l_i}{K} floor}frac{(-1)^k}{(k-1)!}sum_{jgeq k-1}frac{Big(frac{l_i-kK}{L}Big)^j}{(j-(k-1))!}x^j ]

    [=e^{frac{l_i}{L}x}+sum_{k=1}^{lfloorfrac{l_i}{K} floor}frac{(-1)^kBig(frac{l_i-kK}{L}Big)^kx^k}{k!}sum_{jgeq 0}frac{Big(frac{l_i-kK}{L}Big)^j}{j!}x^j+sum_{k=1}^{lfloorfrac{l_i}{K} floor}frac{(-1)^kBig(frac{l_i-kK}{L}Big)^{k-1}x^{k-1}}{(k-1)!}sum_{jgeq 0}frac{Big(frac{l_i-kK}{L}Big)^j}{j!}x^j ]

    [=e^{frac{l_i}{L}x}+sum_{k=1}^{lfloorfrac{l_i}{K} floor}frac{(-1)^kBig(frac{l_i-kK}{L}Big)^kx^k}{k!}e^{Big(frac{l_i-kK}{L}Big)x}+sum_{k=1}^{lfloorfrac{l_i}{K} floor}frac{(-1)^kBig(frac{l_i-kK}{L}Big)^{k-1}x^{k-1}}{(k-1)!}e^{Big(frac{l_i-kK}{L}Big)x} ]

    [=e^{frac{l_i}{L}x}Bigg(1+sum_{k=1}^{lfloorfrac{l_i}{K} floor}frac{(-1)^kBig(frac{l_i-kK}{L}Big)^k}{k!}x^ke^{-kfrac{K}{L}x}+sum_{k=1}^{lfloorfrac{l_i}{K} floor}frac{(-1)^kBig(frac{l_i-kK}{L}Big)^{k-1}}{(k-1)!}x^{k-1}e^{-kfrac{K}{L}x}Bigg) ]

    括号外的部分全部相乘,即为(e^x),考虑括号内的部分,可以发现相乘之后可以表示为若干项(x^{k-j}e^{-kfrac{K}{L}x})的线性组合,于是可以利用以(j,k)为下标的二维卷积计算每一项的系数,就得到了(e^x- ilde P)的一个以若干项(x^ke^{Cx})的线性组合表示的表达式。

    最后,只需要考虑如何计算(sum_{igeq 0}i![x^i](x^ke^{Cx}))即可。考虑:

    [sum_{igeq 0}i![x^i](x^ke^{Cx})=sum_{igeq 0}(i+k)!frac{C^i}{i!}=k!sum_{igeq 0}{{i+k}choose i}C^i ]

    (F_k=sum_{igeq 0}{{i+k}choose i}C^i),于是:

    [F_k=sum_{igeq 0}{{i+k}choose i}C^i=sum_{igeq 0}Bigg({i+k-1choose i-1}+{i+k-1choose i}Bigg)C^i ]

    [=sum_{igeq 1}{i-1+kchoose i-1}C^i+sum_{igeq 0}{i+k-1choose i}C^i ]

    [=Ccdot F_k+F_{k-1} ]

    (F_0=frac{1}{1-C}),于是(F_k=frac{1}{(1-C)^{k+1}}),有(sum_{igeq 0}i![x^i](x^ke^{Cx})=frac{k!}{(1-C)^{k+1}})

    利用前文的分析,用分治( m FFT)计算二维卷积,可以在(O(nLlog nL))的时间内解决问题。最后记得处理边界条件,如(K=l_i)的情况可能要令(0^0=0)

  • 相关阅读:
    组装query,query汇总,query字段
    POJ 1276, Cash Machine
    POJ 1129, Channel Allocation
    POJ 2531, Network Saboteur
    POJ 1837, Balance
    POJ 3278, Catch That Cow
    POJ 2676, Sudoku
    POJ 3126, Prime Path
    POJ 3414, Pots
    POJ 1426, Find The Multiple
  • 原文地址:https://www.cnblogs.com/Mr-Spade/p/14423357.html
Copyright © 2011-2022 走看看