Divide a square into small squares

I have a big square. And I would like to break this square into small squares. I need all possible combinations. I know that there is an infinity of combinations, but I have one limitation. I have a fixed size for the smallest square.

I can realize it with brute force. But it is too long.

What is the preferred algorithm for this task?

Thanks!

+3
source share
3 answers

My math is a little fuzzy, but if you have a square (n ^ 2), then you have the length of one side (n).

From nyou can calculate all the factors for this number and use them as sides for smaller squares ...

.

n^2 = 44100
n = 210

Factors of n = x=2,x=3,x=5,x=7, x= ... and so on.

,

x=2 : x^2 = 4 : 44100 / 4 = 11025 small squares
x=3 : x^2 = 9 : 44100 / 9 = 4900 small squares
x=5 : x^2 = 25 : 44100 / 25 = 1764 small squares
x=7 : x^2 = 49 : 44100 / 49 = 900 small squares

..

+1

, , 2 ( )

1)
2) , , .

, .

3) K- , . K .

, :

N (N beign integer): N * small

 if ((big-size % N*small-size)==0)
    Number += (big-size / N*small-size)^2
 else
    Number += ((big-size / N*small-size)^2) * (big-size % N*small-size)

* ( Nsmall) else , bigsquare N, "" gid N, " " . , ( ), 1, 2 N . ( Nsmall).

, , 3 .

+1

There are no "endless" combinations. In fact, the number may be large, but limited. Moreover, if you need strict squares (width = height, not just rectangles), the smaller, since you need to divide the original square (L sides) into the same integers on both sides, otherwise you will get rectangles as well. If you work with integers, I would recommend just dividing L by 2, 3, ... M (L / M = minimum internal square length).

0
source

Source: https://habr.com/ru/post/1709081/


All Articles