E
E
Egor Trubnikov-Panov2014-12-18 12:46:19
Mathematics
Egor Trubnikov-Panov, 2014-12-18 12:46:19

What is the maximum size of the squares to fit them exactly into a rectangle with known sides?

there is a number of squares n
there is a rectangle with given sides.
all squares must be equal
all squares must fit completely into the rectangle
find the area of ​​one of these squares
Example:
Rectangle 960 by 500 pixels,
there are 10 squares.
it is necessary to shove them entirely into this rectangle so that they are at the same time the maximum possible size.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rsa97, 2014-12-18
@EAT

If you do not need full coverage of the rectangle, then the general algorithm is as follows:
1. Calculate the maximum side of the square = int(sqrt(rectangle_height*rectangle_width/number_squares)) = 219
2. Take the width and height, divide by all numbers from 1 to the number of squares. From the resulting list, we remove all numbers greater than the maximum side of the square, remove duplicates and sort in descending order.
(192, 166, 160, 137, 125, 120, 106, 100, 96, 83, 71, 62, 55, 50)
3. For the obtained sizes, we count the number of squares that fit into the rectangle = int(rectangle_height/square_size)*int (rectangle_width/square_size). As soon as we get a number greater than the required number of squares, we stop.
n(192) = 10
The result is a 5x2 grid with a square side of 192 pixels. 116 free pixels remain vertically.

A
Armenian Radio, 2014-12-18
@gbg

The greatest common divisor of the lengths of the sides of a rectangle. Search by Euclid's algorithm. This will be the side. The area is found by squaring.

P
Puma Thailand, 2014-12-18
@opium

The greatest common divisor will give the size of the side of the square

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question