GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Arrange n people such that a special group never come together ?

Suppose we need to arrange n people such that m of them should never come together? How many possible ways are there ?

asked Dec 8, 2015 by no3

1 Answer

This question can be solved using simple combinatorics logic -
You can treat that group of m people as one person, then total number of people will be (n - m + 1) which can be arranged in (n - m + 1)! ways but remember if n, m are big this value can be too high which can't be stored in simple integer data type, I would suggest you to use string multiplication or biginteger class in Java to calculate that number.
You can read about them at these links -

answered Dec 8, 2015 by utkarsh111