Example of chessboard coverage problem based on Java divide and conquer algorithm

This paper describes the chessboard coverage problem implemented by Java based on divide and conquer algorithm. Share with you for your reference, as follows:

In a chessboard composed of 2 ^ k * 2 ^ k squares, one square is different from others. If the following four L-shaped dominoes are used to cover other squares except this special square, how to cover them. The four L-shaped dominoes are as follows:

The special square in the chessboard is shown in the figure:

The basic principle of implementation is to divide the chessboard of 2 ^ k * 2 ^ k into four sub chessboards of 2 ^ (k - 1) * 2 ^ (k - 1). The special square must be in one of the sub chessboards. If the special square is in a sub chessboard, continue to recursively process the sub chessboard until there is only one square in the sub chessboard. If the special square is not in a sub chessboard, Set the corresponding position in the sub chessboard as the domino number, convert the chessboard without special squares into a sub chessboard with special squares, and then recursively process the sub chessboard. The above principle is shown in the figure:

The specific codes are as follows:

Operation results:

For more information about Java algorithms, readers who are interested can see the topics on this site: Java data structure and algorithm tutorial, summary of Java DOM node operation skills, summary of java file and directory operation skills, and summary of Java cache operation skills

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>