COMBINEIT Editorial

PROBLEM LINK:

Practice

Author: Prathamesh Sogale
Author: Prathamesh Sogale
Editorialist: Yogesh Deolalkar

DIFFICULTY:

Simple.

PREREQUISITES:

Math

PROBLEM:

Aditya recently got selected as a manager in a company. As he was new to the company he wants to be as productive as he can so, in order to boost the productivity of his employees he determined a way, He will form productive team that will try to improve their productivity, his team consist of R employees. Now he needs to determine total no of ways W in which he can select his team.

You are given integer N denoting total number of employees, you need to determine total no of ways W he can select his team of R employees.

SOLUTIONS:

Setter's Solution

cook your dish here

def nCr(n, r):
return (fact(n) // (fact(r)* fact(n - r)))

Returns factorial of n

def fact(n):

res = 1

for i in range(2, n+1):
	res = res * i
	
return res

Driver code

for t in range(int(input())):
n,r=map(int,input().split())
ans=nCr(n, r)
print(ans)

Tester's Solution

cook your dish here

def fact(n):
if n>1:
return n*fact(n-1)
else:
return 1

t = int(input())

while t:
n, r = list(map(int, input().split()))
print(fact(n)//(fact(r)*fact(n-r)))

t-=1