Time Limit:20 Sec
Memory limit:256 MB
Topic Connection
Http://codeforces.com/gym/100187/problem/D
Description
Everyone knows that the Battle of Endor are just a myth fabled by George Lucas in promotion of his movie. Actually, no battle of Endor have happened and the first galactic Empire prospers to this day.
There is creatures of N races living in the first galactic Empire. In order to demonstrate their freedom, equality and brotherhood the Emperor commanded to introduce the holidays. During each of the these holidays creatures of one non-empty subset of races should give gifts to creatures of another non-emp Ty subset of races, not intersecting the first one.
The Emperor ' s stuff is not very strong in maths so what should calculate how many such holidays can be introduced. Holidays is considered different if they differ in the subset of races which give gifts or in the subset of races WHI CH Receive gifts.
Input
The input contains the only integer n (1≤n≤200000)-the number of races living in the first galactic Empire.
Output
Find the number of holidays the Emperor commanded to introduce. This number can is very large, so output the reminder of division of this number by 109 + 9.
Sample Input
2
Sample Output
2
HINT
Test instructions
Each set is a race, and this race will give any set of gifts that have no communion with him, there are n individuals, and ask you how many gifts will you give at the end?
Exercises
Math problem, push formula, push formula, arrange the combination just fine
Code
#include <cstdio>#include<cmath>#include<cstring>#include<ctime>#include<iostream>#include<algorithm>#include<Set>#include<vector>#include<sstream>#include<queue>#include<typeinfo>#include<fstream>#include<map>#include<stack>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineTest Freopen ("Test.txt", "R", stdin)#defineMAXN 2001001#defineMoD 1000000009#defineEPS 1e-9Const intinf=0x3f3f3f3f;Constll infll =0x3f3f3f3f3f3f3f3fll;inline ll Read () {ll x=0, f=1;CharCh=GetChar (); while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//**************************************************************************************ll ANS[MAXN];voidPre () {ans[0]=1; for(intI=1; i<maxn;i++) Ans[i]=ans[i-1]*2, ans[i]%=MoD;} ll Fac[maxn];ll Qpow (ll A,ll b) {ll ans=1; a%=MoD; for(LL i=b;i;i>>=1, a=a*a%MoD)if(i&1) ans=ans*a%MoD; returnans;} ll C (ll n,ll m) {if(m>n| | m<0)return 0; ll S1=fac[n],s2=fac[n-m]*fac[m]%MoD; returnS1*qpow (s2,mod-2)%MoD;}intMain () {fac[0]=1; for(intI=1; i<maxn;i++) Fac[i]=fac[i-1]*i%MoD; Pre (); intn=read (); ll Ans1=0; for(intI=1; i<=n;i++) {ans1+ = (ans[n-i]-1)*C (n,i); Ans1%=MoD; } cout<<ans1<<Endl;}
Codeforces Gym 100187D D. Holidays permutation combination