NOOFBOOK - Editorial

PROBLEM LINK:

Practice

NYRE2020 Contest

Author: Amruta Patil

Tester: Amruta Patil

Editorialist: Amruta Patil

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Basic mathematics operations.

PROBLEM:

Dhanu had been to the NEW YEAR PARTY, she had got some gifts for her friends and even her friends had bought books as a new year present, as she is a book lover. After returning from the party, Dhanu has to arrange the books in shelf(single row shelf) which is of length N cm. Let M be the number of books that she got as a present. Assuming that the width of each book is 3cm. How many books can Dhanu arrange in the shelf from the total number of books M she received as a present.

QUICK EXPLANATION:

Finding No of books each with 3cm width, that can be arranged in the shelf of Ncm out of M no of books.

EXPLANATION:

Here considering M as the no of books she got as a present and N is the length of the single rowed shelf.

Taking N(length of shelf) as input in the first line and M(No of books) as the input in the second line.

The output must be No of books that are arranged on the shelf in the first line and no of books left in second line.

Considering the example:

INPUT:
100
30

For the given input N=100, M=30. The number of books that can be arranged can be found by N/M. The value of N/M would be 33. As there are only 30 books that need to be arranged. The output should be

OUTPUT:
30
0

SOLUTIONS:

Setter's Solution
#include <stdio.h>

int main()

{

int n,m;

scanf("%d", &n);
scanf("%d", &m);

n=n/3;

if(n>=m)
{
printf("%d\n", m);
printf("%d", 0);
}
else
{
printf("%d\n", n);
printf("%d",m-n);
}
return 0;
}