CC's

Back

Patrick Star bought a bookshelf, he named it ZYG !!

Patrick Star has N book .

The ZYG has K layers (count from 1 to K) and there is no limit on the capacity of each layer !

Now Patrick want to put all N books on ZYG :

  1. Assume that the i-th layer has cnti(0≤cnti≤N) books finally.

  2. Assume that f[i] is the i-th fibonacci number (f[0]=0,f[1]=1,f[2]=1,f[i]=f[i−2]+f[i−1]).

  3. Define the stable value of i-th layers stablei=f[cnti].

  4. Define the beauty value of i-th layers beautyi=2stablei−1.

  5. Define the whole beauty value of ZYG score=gcd(beauty1,beauty2,…,beautyk)(Note: gcd(0,x)=x).

Patrick Star wants to know the expected value of score if Patrick choose a distribute method randomly !

分析#

先是两个【——】结论

  • gcd⁡(2a−1,2b−1)=2gcd⁡(a,b)−1\gcd(2^a-1,2^b-1)=2^{\gcd(a,b)}-1
  • gcd⁡(fib(a),fib(b))=fib(gcd⁡(a),gcd⁡(b))\gcd(\text{fib}(a),\text{fib}(b))=\text{fib}(\gcd(a),\gcd(b))

然后原题的score就变成

2fib(gcd⁡(a1,a2,⋯ ))−12^{\text{fib}(\gcd(a_1,a_2,\cdots))}-1

接下来才有机会瞎搞。枚举gcd,d∣nd|n,aa的分配方式有Ck−1n/d+k−1C^{n/d+k-1}_{k-1}种。这种分配包括了d’是d的倍数的所有情况的可能。令F(d)=Ck−1n/d+k−1F(d)=C^{n/d+k-1}_{k-1},f(d)f(d)为真正的数目,于是有

F(d)=∑d∣d′f(d′)F(d)=\sum_{d|d'}f(d')

依照莫比乌斯反演,有

f(d)=∑d∣d′μ(d′d)F(d′)f(d)=\sum_{d|d'}\mu(\frac{d'}{d})F(d')

于是原题得以解决。

[HDU 6363] bookshelf
https://astro-pure.js.org/blog/hdu-6363-bookshelf
Author Cheng Chen
Published at 2020年3月21日
Comment seems to stuck. Try to refresh?✨