# 【bzoj2839】【集合计数】容斥原理+线性求阶乘逆元小技巧

（上不了p站我要死了，侵权度娘背锅）

Description

Input

Output

Sample Input
3 2
Sample Output
6
HINT
【样例说明】

【数据说明】

{{1,2}}，{{1,2,3}}，{{1,2}，{1,2,3}}
{{1,3}}，{{1,3,2}}，{{1,3}，{1,3,2}}
{{3,2}}，{{3,2,1}}，{{3,2}，{3,2,1}}

{{1,2,3}}

AC代码

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
#ifdef WIN32
#define RIN "%I64d"
#else
#define RIN "%lld"
#endif

template <typename T>inline void read(T &res){
T k=1,x=0;char ch=0;
while(ch<'0'||ch>'9'){if(ch=='-')k=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
res=k*x;
}

const int N=1000000+5;
const ll MOD=1e9+7;

ll n,k,jiec[N],niy[N];
ll f[N];

void exgcd(ll a,ll b,ll &x,ll &y){
if(b==0){
x=1,y=0;
return;
}
ll x0,y0;
exgcd(b,a%b,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
ll inverse(ll a){
ll x,y;
exgcd(a,MOD,x,y);
return (x%MOD+MOD)%MOD;
}
void init(){
jiec[0]=niy[0]=1;
/*for(int i=1;i<=n;i++){
jiec[i]=jiec[i-1]*i%MOD;
niy[i]=inverse(jiec[i]);
}*/
for(int i=1;i<=n;i++) jiec[i]=jiec[i-1]*i%MOD;
niy[n]=inverse(jiec[n]);
for(int i=n-1;i>=1;i--) niy[i]=niy[i+1]*(i+1)%MOD;
}
ll power(ll a,ll b,ll mod){
ll rt=1;
for(int i=b;i;i>>=1,a=(a*a)%mod)
if(i&1) rt=(rt*a)%mod;
return rt;
}
ll F(ll x){
/*ll tmp=power(2,x,MOD-1);
return (power(2,tmp,MOD)-1+MOD)%MOD;*/
return (f[x]-1+MOD)%MOD;
}
ll C(ll a,ll b){
if(b>a) return 0;
return jiec[a]*niy[b]%MOD*niy[a-b]%MOD;
}
int main(){
}