ABC156
D
题意:
你有n种花,每种花有一朵。
你可以任意组合但不能使结果为数字a和b,求一共有多少种组合方法。(要求花的数量>=1)
思路:

Lucas + 快速幂 模板题
易推答案为 ans=2^n-1-C(n,a)-C(n,b);

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 +7;
const ll MAXN = 1e6 + 5;

ll p=mod;

inline ll qpow(ll a,ll b){
	ll base=a%p;
	ll ans=1;
	while(b){
		if(b&1) ans=(ans*base)%p;
		base=base*base%p;
		b>>=1;
	}
	return ans;
}

inline ll C(ll n,ll m){
	if(n<m) return 0;//组合数n<m特判
	if(m>n-m) m=n-m;//组合数性质
	ll a=1,b=1;
	for(int i=0;i<m;i++){
		a=(a*(n-i))%p;//组合数分子 a 
		b=(b*(i+1))%p;//组合数分母 b
	} 
	return a*qpow(b,p-2)%p;//费马小定理 a/b=a*b^(p-2) 
}

inline ll Lucas(ll n,ll m){
	if(m==0) return 1;
	return Lucas(n/p,m/p)*C(n%p,m%p)%p;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<(mod+qpow(2,n)-1-(C(n,a)+C(n,b))%mod)%mod;
	return 0;
}

EF待补