我终于知道min-max的期望形式为啥是对的了
题目大意:有n个球,每次等概率的选一个球涂黑。假设T次后所有球都被涂黑了,求
∑
i
=
1
T
i
k
\sum_{i=1}^T i^k
∑i=1Tik的期望。
n
,
k
≤
100
n,k\le100
n,k≤100
题解:这题有很多种推法,自己yy了这么一个:
answer
=
∑
i
≥
1
P
(
i
)
∑
k
=
1
i
j
k
=
∑
j
≥
1
j
k
∑
i
≥
j
P
(
i
)
=
∑
j
≥
1
j
k
(
1
−
∑
i
=
1
j
−
1
P
(
i
)
)
\text{answer}=\sum_{i\ge1}P(i)\sum_{k=1}^ij^k\\ =\sum_{j\ge1}j^k\sum_{i\ge j}P(i)=\sum_{j\ge1}j^k\left(1-\sum_{i=1}^{j-1}P(i)\right)
answer=i≥1∑P(i)k=1∑ijk=j≥1∑jki≥j∑P(i)=j≥1∑jk(1−i=1∑j−1P(i))
考虑后面那坨
G
(
t
)
=
∑
i
=
1
t
P
(
t
)
G(t)=\sum_{i=1}^tP(t)
G(t)=∑i=1tP(t)表示不超过
t
t
t次结束的概率,这显然就是
G
(
t
)
=
S
(
t
,
n
)
t
!
n
t
=
∑
i
=
0
n
(
n
i
)
(
−
1
)
i
(
n
−
i
)
t
n
t
G(t)=\frac{S(t,n)t!}{n^t}=\frac{\sum_{i=0}^n\binom ni(-1)^i(n-i)^t}{n^t}
G(t)=ntS(t,n)t!=nt∑i=0n(in)(−1)i(n−i)t
代回去可得:
answer
=
∑
j
≥
1
j
k
n
j
−
1
−
∑
i
=
0
n
(
n
i
)
(
−
1
)
i
(
n
−
i
)
j
−
1
n
j
−
1
=
∑
j
≥
1
j
k
n
j
−
1
−
∑
i
=
1
n
(
n
i
)
(
−
1
)
i
(
n
−
i
)
j
−
1
−
n
j
−
1
n
j
−
1
=
∑
j
≥
1
j
k
∑
i
=
1
n
(
n
i
)
(
−
1
)
i
+
1
(
n
−
i
)
j
−
1
n
j
−
1
=
∑
i
=
1
n
(
n
i
)
(
−
1
)
i
+
1
∑
j
≥
1
(
n
−
i
)
j
−
1
n
j
−
1
j
k
=
(
−
1
)
n
+
1
+
∑
i
=
1
n
−
1
(
n
i
)
(
−
1
)
i
+
1
n
n
−
i
F
k
(
n
−
i
n
)
\text{answer}=\sum_{j\ge1}j^k\frac{n^{j-1}-\sum_{i=0}^n\binom ni(-1)^i(n-i)^{j-1}}{n^{j-1}}\\ =\sum_{j\ge1}j^k\frac{n^{j-1}-\sum_{i=1}^n\binom ni(-1)^i(n-i)^{j-1}-n^{j-1}}{n^{j-1}}\\ =\sum_{j\ge1}j^k\frac{\sum_{i=1}^n\binom ni(-1)^{i+1}(n-i)^{j-1}}{n^{j-1}}\\ =\sum_{i=1}^n\binom ni(-1)^{i+1}\sum_{j\ge1}\frac{(n-i)^{j-1}}{n^{j-1}}j^k\\ =(-1)^{n+1}+\sum_{i=1}^{n-1}\binom ni(-1)^{i+1}\frac{n}{n-i}F_k\left(\frac{n-i}{n}\right)
answer=j≥1∑jknj−1nj−1−∑i=0n(in)(−1)i(n−i)j−1=j≥1∑jknj−1nj−1−∑i=1n(in)(−1)i(n−i)j−1−nj−1=j≥1∑jknj−1∑i=1n(in)(−1)i+1(n−i)j−1=i=1∑n(in)(−1)i+1j≥1∑nj−1(n−i)j−1jk=(−1)n+1+i=1∑n−1(in)(−1)i+1n−inFk(nn−i)
其中:
F
k
(
q
)
=
∑
i
≥
1
q
i
i
k
F
k
(
q
)
q
−
1
=
∑
i
≥
1
q
i
(
i
+
1
)
k
F
k
(
q
)
q
−
1
=
∑
i
≥
1
q
i
∑
j
=
0
k
(
k
j
)
i
j
F
k
(
q
)
q
−
1
=
∑
j
=
0
k
(
k
j
)
F
j
(
q
)
=
F
k
(
q
)
+
∑
j
=
0
k
−
1
(
k
j
)
F
j
(
q
)
F
k
(
q
)
=
q
1
−
q
(
1
+
∑
j
=
0
k
−
1
(
k
j
)
F
j
(
q
)
)
F
0
(
q
)
=
q
1
−
q
F_k(q)=\sum_{i\ge1}q^ii^k\\ \frac{F_k(q)}{q}-1=\sum_{i\ge1}q^i(i+1)^k\\ \frac{F_k(q)}{q}-1=\sum_{i\ge1}q^i\sum_{j=0}^k\binom kji^j\\ \frac{F_k(q)}{q}-1=\sum_{j=0}^k\binom kj F_j(q)=F_k(q)+\sum_{j=0}^{k-1}\binom kj F_j(q)\\ F_k(q)=\frac{q}{1-q}\left(1+\sum_{j=0}^{k-1}\binom kjF_j(q)\right)\\ F_0(q)=\frac{q}{1-q}
Fk(q)=i≥1∑qiikqFk(q)−1=i≥1∑qi(i+1)kqFk(q)−1=i≥1∑qij=0∑k(jk)ijqFk(q)−1=j=0∑k(jk)Fj(q)=Fk(q)+j=0∑k−1(jk)Fj(q)Fk(q)=1−qq(1+j=0∑k−1(jk)Fj(q))F0(q)=1−qq
这样就可以在O(nk^2)的时间解决本题
还有一些平方时间复杂度做法QwQ
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define lint long long
#define p 998244353
#define ull unsigned lint
#define db long double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gc getchar()
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
typedef set<int>::iterator sit;
inline int inn()
{
int x,ch;while((ch=gc)<'0'||ch>'9');
x=ch^'0';while((ch=gc)>='0'&&ch<='9')
x=(x<<1)+(x<<3)+(ch^'0');return x;
}
const int N=110;
int C[N][N],f[N];
inline int fast_pow(int x,int k,int ans=1) { for(;k;k>>=1,x=(lint)x*x%p) (k&1)?ans=(lint)ans*x%p:0;return ans; }
inline int inv(int x) { return fast_pow(x<0?x+p:x,p-2); }
inline int sol(int x,int s) { return (s&1)?(x?p-x:0):x; }
inline int prelude(int n)
{
rep(i,0,n) C[i][0]=1;
rep(i,1,n) rep(j,1,i) C[i][j]=C[i-1][j]+C[i-1][j-1],(C[i][j]>=p?C[i][j]-=p:0);
return 0;
}
inline int F_k(int q,int k)
{
int v=(lint)q*inv(1-q)%p;f[0]=v;
rep(i,1,k)
{
f[i]=1;
rep(j,0,i-1) f[i]=(f[i]+(lint)C[i][j]*f[j])%p;
f[i]=(lint)v*f[i]%p;
}
return f[k];
}
int main()
{
int n=inn(),k=inn(),q,ans=0;prelude(max(n,k));
rep(i,1,n-1)
q=(lint)inv(n)*(n-i)%p,
ans+=sol((lint)C[n][i]*inv(q)%p*F_k(q,k)%p,i+1),
(ans>=p?ans-=p:0);
ans+=sol(1,n+1),(ans>=p?ans-=p:0);
return !printf("%d\n",ans);
}