Tuesday 21 February 2017

Splitting into Teams

QUESTION DESCRIPTION :

During the Physical Education hour, PT sir has decided to conduct some team games. He wants to split the students in the class into equal sized teams. In some cases, there may be some students who are left out from teams and he wanted to use the left out students to assist him in conducting the team games.
For instance, if there are 50 students in the class and if the class has to be divided into 7 equal sized teams, 7 students will be there in each team and 1 student will be left out.
PT sir asks your help to automate this team splitting task. Can you please help him out?

Input Format:
Input consists of 2 integers. The first integer corresponds to the number of students in the class and the second integer corresponds to the number of teams.


TEST CASE 1

INPUT

60
8

OUTPUT

The number of students in each team is 7 and left out is 4


TEST CASE 2

INPUT

100
22

OUTPUT

The number of students in each team is 4 and left out is 12


EXPLANATION :

The code is a basic mathematics problem which uses the divide and modulo operation , to calculate the number of people in each group and the number of people left out after equal division in groups.

For counting the number of people in each group , we use the / operation and for the people left out we use the % operation
 
The input format is two integers , first one is the number of students in total and the second one is the number of teams to be formed


ALGORITHM : 

  • Take two inputs from the user , for number of students and teams ( a,b )
  • Calculate the number of people in each team ( a/b )
  • Calculate the number of people left out ( a%b )
  • Print the result with appropriate message
 
SOLUTION : (Please use this as reference only)

CODE

No comments:

Post a Comment