题目链接:点击打开链接
大意:每一个集合都可以是一个种族,每个假日选定一些种族作为一个集合,这个集合应该给任何与他没有相交的种族礼物,有n个种族,问你最后要给多少假日?
在每一个假日中,一个非空的种族的成员都应该给另一个非空的种族的成员提供礼物。
两个假日中,如果集合分别给不同的种族礼物,那么这两个假日被认为是不同的 。
题解:首先选出 i 个种族作为一个集合(送礼物的),然后给剩下 n-i 个种族送礼物。即:
#include<cstdio>
#include<algorithm>
#include<cstring>
#define LL long long
using namespace std;
const LL MOD=1e9+9;
LL n;
LL fac[200010];
LL qpow(LL a,LL b)
{
LL ans=1;
while(b)
{
if(b&1)
ans=ans*a%MOD;
a=a*a%MOD;
b>>=1;
}
return ans;
}
LL C(LL x,LL y)
{
return fac[x]*qpow(fac[x-y],MOD-2)%MOD*qpow(fac[y],MOD-2)%MOD;
}
int main()
{
fac[0]=1;
for(int i=1;i<200001;i++)
fac[i]=fac[i-1]*i%MOD;
while(~scanf("%lld",&n))
{
LL ans=0;
for(int i=1;i<n;i++)
{
ans=(ans+C(n,i)*(qpow(2,n-i)-1)%MOD)%MOD;
}
printf("%lld\n",ans);
}
return 0;
}