Canna

Monday, 24 September 2018

Splitting into Teams

Problem 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 (stdin)
    60
    
    8
    
    
    Expected Output
    The number of students in each team is 7 and left out is 4
  • Test Case 2

    Input (stdin)
    100
    
    22
    
    
    Expected Output
    The number of students in each team is 4 and left out is 12
  • Program
  • #include <stdio.h>
    int main()
    {
      int a,b,t,n;
      scanf("%d",&a);
      scanf("%d",&b);
      t=a/b;
      n=a%b;
      printf("The number of students in each team is %d and left out is %d ",t,n);
      
     return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.