题目链接: B 抓球 #include<bits/stdc++.h> using namespace std; #define int long long const int maxn=2e5+5; const int mod=1e9+7; int a[maxn]; int sp(int a,int b) { int sum=1; while(b) { if(b&1) sum=sum*a%mod; a=a*a%mod; b/=2; } return sum; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); a[0] = 1; for(int i =1; i <= 2e5; i ++ ) a[i] = a[i - 1] *i % mod; int n,x,y,k; int t; cin>>t; while(t--) { int q; cin>>x>>y>>k>>q; if(k>x) { cout<<0<<endl; continue; } int p=(a[x]*a[x+y-k]%mod)*sp(a[x-k]*a[x+y]%mod,mod-2)%mod; cout<<sp(p,q)<<endl; } }