Political Science, asked by sudu123, 9 months ago

X girls and Y boys are standing in a line. If too many girls stand together, they will start fighting
with each other. Similarly, if too many boys stand together, they will start fighting with each
other. You are their new Physical Education teacher and you want to minimize the chances of
them fighting. Hence, you have decided to rearrange them such that maximum number of
boys/girls standing together is minimum.
For Example: If there are 5 girls and 1 boy standing, then, 3 girls (at least) will be standing
together at any cost.
Input
* Two numbers X and Y representing number of girls and number of
boys.
Output
* Single integer representing maximum of (maximum number of boys
or maximum number of girls) standing together in an optimal arran
gement.
Constraints
1<=X,Y<=1000​

Answers

Answered by abhishar07
3

Answer:

First find the total number of ways in which boys can be arrange on round table.

No. of ways to arrange boys on table = (n-1)!

After making boys arrangement, now make arrangement for girls. As after seating boys there are n space available between them. So there are n position and n number of girls. So total number of arrangement in which girls sit between boys are n!.

Therefore Total number of ways = (number of arrangement of boys) * (number of ways to sit girl among boys) = (n-1)! * (n!)

Explanation:

MAYBE THIS HELPS US..

Answered by poojan
2

Program on 'placement of boys and girls' :

Language used : Python Programming.

Program :

import math

girls=int(input())

boys=int(input())

y=max([boys,girls])

if boys==girls+1 or girls==boys+1 or boys==girls:

   print("No group of boys or girls are standing together.")

elif y==boys:

   boys=boys-(girls+1)

   print("After arranging, atleast {0} boys are standing together".format(boys))

elif y==girls:

   girls=girls-(boys+1)

   print("After arranging, atleast {0} girls are standing together".format(girls))

Test cases :

Input 1 :

Enter the no.of girls present : 5

Enter the no.of boys present : 1

Output 1:

After arranging, atleast 3 girls are standing together

Input 2 :

Enter the no.of girls present : 2

Enter the no.of boys present : 12

Output 2:

After arranging, atleast 9 boys are standing together

Input 3 :

Enter the no.of girls present : 2

Enter the no.of boys present : 3

Output 3:

No group of boys or girls are standing together.

Input 4 :

Enter the no.of girls present : 3

Enter the no.of boys present : 3

Output 4:

No group of boys or girls are standing together.

Learn more :

1. Write a simple python function to increase the value of any number by a constant "C=5"...

https://brainly.in/question/16322662

2. What is the functionality of the following python code?...

https://brainly.in/question/12246161

Similar questions