Given the length, breadth, height of a cuboid. The task is to divide the given cuboid in minimum number of cubes such that size of all cubes is same and sum of volumes of cubes is maximum.
Input : l = 2, b = 4, h = 6 Output : 2 6 A cuboid of length 2, breadth 4 and height 6 can be divided into 6 cube of side equal to 2. Volume of cubes = 6*(2*2*2) = 6*8 = 48. Volume of cuboid = 2*4*6 = 48. Input : 1 2 3 Output : 1 6
First of all, we are not allowed to waste volume of cuboid as we meed maximum volume sum. So, each side should be completely divide among all cubes. And since each of three side of cubes are equal, so each side of the cuboid need to be divisible by same number, say x, which will going to be the side of the cube. So, we have to maximize this x, which will divide given length, breadth and height. This x will be maximum only if it is greatest common divisor of given length, breadth and height. So, the length of the cube will be GCD of length, breadth and height.
Now, to compute number of cubes, we know total volume of cuboid and can find volume of one cube (since side is already calculated). So, total number of cubes is equal to (volume of cuboid)/(volume of cube) i.e (l * b * h)/(x * x * x).
Below is implementation of this approach:
- Check if a point is inside, outside or on the parabola
- Minimum product subset of an array
- Divide 1 to n into two groups with minimum sum difference
- Maximum number of customers that can be satisfied with given quantity
- Find the Surface area of a 3D figure
- Program to calculate area and volume of a Tetrahedron
- Program to check if water tank overflows when n solid balls are dipped in the water tank
- Program to calculate Volume and Surface area of Hemisphere
- Partition into two subarrays of lengths k and (N - k) such that the difference of sums is maximum
- Maximize volume of cuboid with given sum of sides
- Program to calculate volume of Ellipsoid
- Program for Volume and Surface Area of Cuboid
- Find the minimum and maximum amount to buy all N candies
- Fractional Knapsack Problem
- Minimize Cash Flow among a given set of friends who have borrowed money from each other
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : vt_m