"Problem description"
In a chessboard of 2^k * 2^k squares, if a square is different from other squares, it is called a special square, which is called a special chessboard. It is obvious that special squares appear on the board in the 4^k case. Thus for any k>=0, there are 4^k different special chessboard. The special chessboard shown is one of the 16 special chessboard in k=2.
Figure A
In the board coverage problem, the different forms of the L-type dominoes in 4 are used to cover all squares except special squares on a given special chess card, and any 2 L-type dominoes shall not overlap. It is easy to know that in any 2^k * 2^k chessboard, the number of L-type dominoes used is exactly (4^k-1)/3. Now give the size of the chessboard and the location of the special squares, please find this board.
Figure II
"Sample Input"
2
0 0
"Sample Output"
0 1
1 1
"Problem-solving ideas"
At first glance, it is difficult to feel this topic, we can use the idea of divided treatment, like figure one, a large board is continuously divided into four parts, until each part contains only one square, then the recursive boundary is out. Then for each part, we need to find a special box, we need to see whether this special box is in the range we are looking for, if it is, continue to find, not, the symmetry of the part with the L-shaped card cover, and then find the number of the L-shaped brand covered area. See the code.
"Code Implementation"
1 varTile,size,k,i,x,y,j:longint;2A:Array[-1.. -,-1.. -] ofLongint;3 proceduretry (tr,tc,dr,dc,size:longint);4 varS,t:longint;5 begin6 ifSize=1 Then7 exit;8t:=tile;//number of L-type cards9 Inc (tile);TenS:=sizeDiv 2; One if(Dr<tr+s) and(Dc<tc+s) Then//find out if in the upper left corner, in, continue looking for A try (tr,tc,dr,dc,s) - Else//No , the lower right corner with the L-card cover, find the L-shaped card - begin thea[tr+s-1, tc+s-1]:=T; -Try (tr,tc,tr+s-1, tc+s-1, s); - End; - if(Dr<tr+s) and(Dc>=tc+s) Then//find out if in the top right corner +Try (tr,tc+s,dr,dc,s) - Else//Do not cover the lower left corner with an L-card + begin Aa[tr+s-1, tc+s]:=T; atTry (tr,tc+s,tr+s-1, tc+s,s); - End; - if(Dr>=tr+s) and(Dc<tc+s) Then//find out if in the lower left corner -Try (tr+s,tc,dr,dc,s) - Else//Do not overwrite the upper right corner with the L-shaped card - begin ina[tr+s,tc+s-1]:=T; -Try (tr+s,tc,tr+s,tc+s-1, s); to End; + if(Dr>=tr+s) and(Dc>=tc+s) Then//find out if in the lower right corner -Try (tr+s,tc+s,dr,dc,s) the Else//Do not overwrite the upper left corner with the L-shaped card * begin $a[tr+s,tc+s]:=T;Panax NotoginsengTry (tr+s,tc+s,tr+s,tc+s,s); - End; the End; + begin A readln (size); the readln (x, y); +tile:=1; -Try0,0, x,y,size); $ fori:=0 tosize-1 Do $ begin - forj:=0 tosize-1 Do -Write (A[i,j]:3,' '); the Writeln; - End;Wuyi End.
The problem of board coverage