# [SOLUTION] Board Exam solution codechef 2021 – Code Cracker codechef

## Board Exam solution codechef 2021

Sneha is giving her board exam in Science. And her question paper has Part A and Part B, each containing NN questions. If she has to choose XX questions from part A and YY questions from part B. Help Sneha to find out how many ways can she choose the question.

Each part should have at least 1 question.

### Input: Board Exam solution codechef 2021

• First-line will contain TT, the number of test cases. Then the test cases follow.
• Each test case contains a single line of input, three integers N,X,YN,X,Y.

### Output:

• Output a single line containing the number of possible ways in which Sneha can choose the question.

### Constraints

• 1T10001≤T≤1000
• 1N1001≤N≤100
• 0<X<N0<X<N
• 0<Y<N0<Y<N

### Sample Input: Board Exam solution codechef 2021

1
10 8 5


### Sample Output:

11340

### Problem Code :

c++

#include <iostream>
using namespace std;

unsigned long long fact(int n){
unsigned long long factorial = 1;

for(int i = 1; i <=n; ++i) {
factorial *= i;
}

return factorial;
}

int main() {
int t;
cin>>t;

int n,x,y;
unsigned long long first,second;
while(t>0){
cin>>n>>x>>y;
first = fact(n)/(fact(x)*fact(n-x));
second = fact(n)/(fact(y)*fact(n-y));
cout<<first*second<<endl;
t--;
}

return 0;
}
PYTHON

def nCr(n, r):
return (fact(n) / (fact(r)
* fact(n - r)))
def fact(n):
res = 1
for i in range(2, n+1):
res = res * i
return res
for t in range(int(input())):
n,x,y=map(int, input().split())
print(int(nCr(n, x)*nCr(n, y)))


Java

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;

class Code
{
public static int factorial(int n)
{
int res = 1, i;
for (i=2; i<=n; i++)
res *= i;
return res;
}
public static void main (String[] args) throws java.lang.Exception
{
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t-->0){
int n=s.nextInt();
int x=s.nextInt();
int y=s.nextInt();
BigDecimal a=new BigDecimal(factorial(n));
a=a.multiply(a);
//long result=factorial(n)*factorial(n);
BigDecimal b=new BigDecimal(factorial(x));
BigDecimal c=new BigDecimal(factorial(y));
BigDecimal d=new BigDecimal(factorial(n-x));
BigDecimal e=new BigDecimal(factorial(n-y));
b=b.multiply(c);
b=b.multiply(d);
b=b.multiply(e);
//int result1=(factorial(x)*factorial(y)*factorial(n-x)*factorial(n-y));

System.out.println(a.divide(b));
}
}
}