C Programming Language
Problem Title : Container
Today is Jojo’s birthday. To prepare the birthday party, Jojo asks Bibi to bring N cubes with edge length S for the game on his birthday party. The only idea that came up to Bibi’s mind is to bring the cubes with rectangular box containers. Then Bibi went to a store. The only container available in the store is a container with size A × B × C. Bibi is a thrifty person. Therefore, she wants to buy the minimum number of containers so that she can load all the cubes. As a good friend of Bibi, help her to calculate the minimum numbers of containers she must buy.
Format Input
In this case, the input of this problem starts with a line contains 5 integers N S A B C consecutively as the number of cubes, the edge length of cube, the length of the container, the width of the container, and the height of the container.
Format Output
The output of this problem consists of an integer describing the minimum number of containers Bibi must buy.
Constraints
Sample Input & Output (1) (standard input & output)
24 4 8 8 8
3
Sample Input & Output (2) (standard input & output)
27 3 8 4 10
5
Note: If you have any confusion feel free to comment ..i will try to help you out ...but do not give negative rating to the question as it affects my answering rights....
Note:I have only used basic unitry maths here so dont think too much of wht has been done..if you dont get something comment below...but dont panic...
#include <stdio.h>
#include <math.h>
int main() {
int N,S,A,B,C;
printf("Enter values of N, S, A, B, and C: ");
scanf("%d %d %d %d %d",&N,&S,&A,&B,&C);
A=A/S;//the variable A stores the total length which is completely
//occupied by S
B=B/S;//total width completely occupied by S
C=C/S;//total height completely occupied by S
int no=ceil((double)N/(A*B*C));//we do a round up because the output required is the count of containers
//for eg 4.78 means that it has actually 5 containers requirement
//
printf("The total no of rectangular containers required are: %d",no);
return 0;
}
Output:->
Get Answers For Free
Most questions answered within 1 hours.