**Problem link:** CodeChef: Practical coding for everyone

**Author and Editorialist:** saloni_203

**DIFFICULTY:**

CAKEWALK

**PREREQUISITES:**

None

**PROBLEM:**

Sneha is giving her board exam of Science. And her question paper has two parts Part A and Part B, each containing “N” questions. If she has to choose “X” questions from part A and “Y” questions from part B.

Then how many ways can she choose the questions.

Each part should have at least 1 question.

**QUICK EXPLANATION:**

Key to success : Anyone with good knowledge of combination can do this question very, very easily.

Sneha has to generate the combination of [N, X] and [N, Y].

**EXPLANATION:**

There are N questions in part A out of which X questions can be chosen in C(N, X) ways. Similarly, Y questions can be chosen from part B containing N questions in C(N, Y) ways.

So. the total number of ways of selecting x questions from part A and y questions from part B is C(N, X) * C(N, Y).

**SOLUTION:**

## Editorialist's Solution

#include<bits/stdc++.h>

using namespace std;

int fact(int);

int main()

{

int T;

cin>>T;

while(T–)

{

int n,x,y;

cin>>n>>x>>y;

if(n>=1 && x>0 && x<n && y>0 && y<n)

{

long long int w = (fact(n)/(fact(n-x)*fact(x))) * (fact(n)/(fact(n-y)*fact(y)));

cout<<w<<endl;

}

}

}

int fact(int l)

{

int i,f=1;

for(i=1;i<=l;i++)

{

f=f * i;

}

return f;

}