|
发表于 2004-7-13 01:15:58
|
显示全部楼层
uuuhhhhhhhhh
you are interested in how many knights you can place on the board, so with my solution, I basically put down the first knight, then mark all the positions which can be reached by that knight, and you can put down the next knight at each of the remaining unmarked positions. of course you will need to have a counter for each constellation of the knights, and another for the maximum number of knights you are able to place in the board with the best constellation.
for example, there are n possible positions for placing the first knight, FOR EACH of the n initial positions, you do the pattern matching thing with the big and small board, so you can easily mark the positions reachable by the knight, assuming that the big board already contain all these points(you do this calculation only ONCE at the beginning ie i+/- 2, k+/- 2 ...).
the next step would be to decide how you want to place your second knight(in one of the m remaining blocks). so you repeat the above procedure recursively FOR EACH of the remaining points, and after each recursive call you will have a smaller set of points. you will eventually find out that you can't put down any more knights, because when you overlap the two boards, the "1"'s in the big board will overlap onto the "1"'s in the small one. This means if you put the knight down, it will be able to meet one of the existing knights after some moves.
understood? now you may have realized that it will take n*m*.... iterations to to through all the constellations. but when you look at the check board, you will realize e.g. if you first put down a knight at a corner, no matter which one, your final result will be identical, due to the symmetry of the chess board. so you only consider the initial positions that will yield different outcomes. This trick will prevent lots of unnecessarily repeated computation.
<<晕,你们到底是研究研究的是马的冲突问题还是马踏棋盘问题?说着说着就跑题!
so now you should(hopefully) see that, these two are really the same problem; without traversing the whole chessboard in all possible paths, how do find the optimal solution? but theoretically, there should be a more elegent mathematical solution, which i don't know. That's why I have gone through all the trouble to describe this solution. let me know if you can solve the problem in a few lines(I really think it is possible). |
|