Alen Avdibegović
@gordonramiz007
Bosnia And Herzegovina, Sarajevo
Joined Feb 2023
World Rank: #54501 (0.3 points)
Institution: JU OS Musa Cazim Catic
007 #include <iostream> #include <vector> typedef long long ll; using namespace std; vector<ll> fact(1e6+1), rfact(1e6+1); const ll MOD = 1e9+7; ll n, a, b, d, mid; ll bincoef(ll f, ll s) { return (((fact[f]*rfact[s])%MOD)*rfact[f-s])%MOD; } ll binexpo(ll f, ll s) { if(!s) return 1; mid = binexpo(f, s/2); mid*=mid; mid%=MOD; if(s%2) mid=(mid*f)%MOD; return mid; } int main() { fact[0] = 1; fact[1] = 1; rfact[0] = 1; for(ll i = 2; i <= 1e6+1; i++) { fact[i-1] = fact[i-2]*(i-1) % MOD; rfact[i-1] = binexpo(fact[i-1], MOD-2); } while(cin >> n >> a >> b >> d) cout << (bincoef(n, a)*(binexpo(bincoef(b, d), a)%MOD)%MOD) << "\n"; }