Case partition ideas

Divide and conquer algorithm idea is a classic idea. To always be recalled that the idea to jot down the partition of cases I have encountered! Long-term update this post, please share!

 

1, farmers divided the land:

Suppose you are a farmer, there is a small land, 1680 * 640 is so big, you want to land evenly into the box, the box is large enough to make the separation, should be how to divide?

Idea: divide and conquer is the core every time a small problem becomes a big problem, reduce the size of each recursive are problems, then that is a description of baseline conditions to solve the problem (simpler description)

Base Line conditions for this problem is the length of a side when the separation of smaller land is an integer multiple of the other side, the main function of practices: starting from the shorter piece of land side, draw a square, until leaving a small land, and then determines if the base of the smaller land condition is satisfied (the other side is an integral multiple of the side, it indicates that the fold can draw small blocks) of the shorter side is the maximum long side of the box, or on a small piece of land continue to call the main function, until you find the location

 

The title data: 1680 * 640 => 400 * 640 => 240 * 400 => 240 * 160 => 80 * 160 (satisfying baseline condition), from baseline here backstepping, the previous large squares all reduce 80 * 80 the small box! 

Case Source: "algorithm graphic"

Guess you like

Origin www.cnblogs.com/FlyingZiming/p/11427424.html