#include<bits/stdc++.h> #define x first #define y second #define PB push_back #define mst(x,a) memset(x,a,sizeof(x)) #define all(a) begin(a),end(a) #define rep(x,l,u) for(ll x=l;x<u;x++) #define rrep(x,l,u) for(ll x=l;x>=u;x--) #define sz(x) x.size() #define IOS ios::sync_with_stdio(false);cin.tie(0); using namespace std; typedef unsigned long long ull; typedef pair<int,int> PII; typedef pair<char,char> PCC; typedef long long ll; typedef pair<ll,ll> PLL; const int N=2*1e5+10; const int M=1e5+10; const int INF=0x3f3f3f3f; const int mod=1e9+7; void solve(){ int n,x,pos;cin>>n>>x>>pos; int left=0,right=0; int l=0,r=n; while(l<r){ int mid=l+r>>1; if(mid>pos) right++,r=mid; else left+=mid!=pos,l=mid+1; } if(x-1<left || n-x<right){ cout<<0<<endl; return; } ll res1=1,res2=1,fact=1; rep(i,1,left+1) res1=(res1*(x-i))%mod; rep(i,1,right+1) res2=(res2*(n-x-i+1))%mod; rep(i,1,n-1-left-right+1) fact=(fact*i)%mod; cout<<res1%mod*res2%mod*fact%mod<<endl; } int main(){ IOS; //freopen("test.txt", "r", stdin); //freopen("test.txt", "w", stdout); //int t;cin>>t; //while(t--) solve(); return 0; }
本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。
我来说两句