题目链接:​​点击打开链接​


D. Holidays



time limit per test



memory limit per test



input



output



Everyone knows that the battle of Endor is just a myth fabled by George Lucas for promotion of his movie. Actually, no battle of Endor has happened and the First Galactic Empire prospers to this day.

n

The Emperor's stuff is not very strong in maths so you should calculate how many such holidays can be introduced. Two holidays are considered different if they differ in the subset of races which give gifts or in the subset of races which receive gifts.



Input



n (1 ≤ n ≤ 200000) — the number of races living in the First Galactic Empire.



Output



109.



Examples



input



2



output



2



input



3



output



12



input



5



output



180



input



200000



output



82096552






大意:每一个集合都可以是一个种族,每个假日选定一些种族作为一个集合,这个集合应该给任何与他没有相交的种族礼物,有n个种族,问你最后要给多少假日?

在每一个假日中,一个非空的种族的成员都应该给另一个非空的种族的成员提供礼物。

两个假日中,如果集合分别给不同的种族礼物,那么这两个假日被认为是不同的 。 


题解:首先选出 i 个种族作为一个集合(送礼物的),然后给剩下 n-i 个种族送礼物。即:

codeforces-gym-100187-D【组合数】【逆元】_ide

#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;
}