Problem link: CodeChef: Practical coding for everyone
Author and Editorialist: saloni_203
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.
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].
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).
using namespace std;
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)));
int fact(int l)
f=f * i;