➤ Problem Link : ADATEAMS
👉 Hint : edit please
✅ C++ Solution :
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define m 1000000007
ll dp[1000002];
ll power(ll x,ll n)
{
if(n==0)
return 1;
ll y=power(x,n/2);
y=(y*y)%m;
if(n%2 != 0)
y=(y*x)%m;
return y;
}
ll comb(int n,int r)
{
ll l=min(n-r-1,r-1);
ll num=1,den=1;
ll temp=power(dp[n-l-1],m-2);
num=(dp[n]*temp)%m;
den=dp[l+1];
den=power(den,m-2);
return (num*den)%m;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,a,b,d;
dp[0]=1;
for(ll i=1;i<=1000002;i++)
dp[i]=(dp[i-1]*i)%m;
while(scanf("%d %d %d %d",&n,&a,&b,&d)!=EOF)
{
ll x=comb(n,a);
ll y=comb(b,d);
y=power(y,a);
x=(x*y)%m;
cout<<x<<"\n";
}
}
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!
