Question 3 – Alisa In the Library

Alisa In the Library

Here, in this page we will discuss one of the problem Alisa in the library that was asked in InfyTQ Advance Coding Section. We will discuss the problem description along with function description, Test Cases along with there explanation.

You will find the solution of the problem in different programming language. 

Alisa In the Library

Problem Statement -: 

Alisa is in the library, she wants to buy some different books, there are “nm” different chemistry books and k different science books. In how many different ways can Alisa select a book of mathematics, two books of chemistry, and some books of science?

 

Function Description:

  • Complete the books function in the editor below. It has the following parameter(s):

Parameters:

NameTypeDescription
nIntegerthe number of mathematics books
mIntegerthe number of chemistry books
kIntegerthe number of science books
xIntegerthe number of books of science Alisa needs

Return: The function must return an INTEGER denoting the number of ways Alisa can buy the books she needs.

 

Constraints:

  • 1 <= n <= 10^6
  • 1 <= m <= 10^6
  • 1 <= k <= 10^6
  • 1 <= x <= 10^6

 

Input Format:

  • The first line contains an integer, n, denoting the number of mathematics books.
  • The next line contains an integer, m, denoting the number of chemistry books.
  • The next line contains an integer, k, denoting the number of science books.
  • The next line contains an integer, x, denoting the number of books of science Alisa needs.

 

OUTPUT DESCRIPTION

We have 5 different mathematics books, four different chemistry books, and two different science books which we have to choose all of them (d=2) so, we can choose 1 book out of five mathematics books in 5 ways, 2 out of 4 chemistry books in 6 ways, and we have only one way to choose 2 out of 2 science books, total: 5*6*1 = 30 ways. 

 

Sample Test Cases

  • Sample Input 1
    5
    4
    2
    2
  • Sample Output 1
    30