Number of ways to arrange 2 * N persons on the two sides of a table with X and Y persons on opposite sides |  ; Function to find factorial of a number ; Function to find nCr ; Function to find the number of ways to arrange 2 * N persons ; Driver code ; Function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; int factorial ( int n ) { if ( n <= 1 ) return 1 ; return n * factorial ( n - 1 ) ; } int nCr ( int n , int r ) { return factorial ( n ) / ( factorial ( n - r ) * factorial ( r ) ) ; } int NumberOfWays ( int n , int x , int y ) { return nCr ( 2 * n - x - y , n - x ) * factorial ( n ) * factorial ( n ) ; } int main ( ) { int n = 5 , x = 4 , y = 2 ; cout << NumberOfWays ( n , x , y ) ; return 0 ; }