Hi all. Recently I saw such a task. But problems arose with the decision. Would appreciate your help.

There are m men and w women. A deputation of exactly 3 people has to be formed from them. A deputation is diverse if and only if it contains at least one man and at least one woman. How many distinct ways are there to select a diverse deputation of 3 people? Two deputations are different if and only if one deputation has a member which the other does not have.

Find the number of ways to select a diverse deputation of 3 people.

Function Description

Complete the function diverseDeputation in the editor below. The function must return an integer which is the number of ways to select a diverse deputation from m men and w women.

Constraints

0 ≤ m, w ≤ 1000

/*

* Complete the 'diverseDeputation' function below.

*

* The function is expected to return an INTEGER.

* The function accepts the following parameters:

* 1. INTEGER m

* 2. INTEGER w

*/

function diverseDeputation(m, w) {

// Write your code here

}

There are m men and w women. A deputation of exactly 3 people has to be formed from them. A deputation is diverse if and only if it contains at least one man and at least one woman. How many distinct ways are there to select a diverse deputation of 3 people? Two deputations are different if and only if one deputation has a member which the other does not have.

Find the number of ways to select a diverse deputation of 3 people.

Function Description

Complete the function diverseDeputation in the editor below. The function must return an integer which is the number of ways to select a diverse deputation from m men and w women.

Constraints

0 ≤ m, w ≤ 1000

/*

* Complete the 'diverseDeputation' function below.

*

* The function is expected to return an INTEGER.

* The function accepts the following parameters:

* 1. INTEGER m

* 2. INTEGER w

*/

function diverseDeputation(m, w) {

// Write your code here

}

asked March 23rd 20 at 19:24

1 answer

answered on March 23rd 20 at 19:26

And what's the problem?

Kolichestvennaya * Kolichestvennye + kolichestvennaia * kolichestvom

(m * (m - 1) / 2) * w + (w * (w - 1) / 2) * m =

= (m * w * (m + w - 2)) / 2

Kolichestvennaya * Kolichestvennye + kolichestvennaia * kolichestvom

(m * (m - 1) / 2) * w + (w * (w - 1) / 2) * m =

= (m * w * (m + w - 2)) / 2

Find more questions by tags JavaScript