残缺棋盘问题

残缺棋盘问题
残缺棋盘是一个2^k*2^k个方格的棋盘,其中恰好有一个方格残缺,现在要求用三格板覆盖棋盘,在此覆盖中两块三格板不能重叠,三格板也不能覆盖在残缺的方格上。

#include
   
   
    
    
#include
    
    
     
     
#include
     
     
      
      

using namespace std;

const int N = 104;

int board[N][N];        //棋盘大小

int tile = 1;          //L型骨牌号

void TileBoard(int tr, int tc, int dr, int dc, int size)
{
    if(size==1) return ;
    int t=tile++;
    int s=size/2;           //分割棋盘
    if(dr
      
      
       
       
         =tc+s) TileBoard(tr, tc+s, dr, dc, s); else { board[tr+s-1][tc+s]=t; TileBoard(tr, tc+s, tr+s-1, tc+s, s); } if(dr>=tr+s&&dc 
        
          =tr+s&&dc>=tc+s) TileBoard(tr+s, tc+s, dr, dc, s); else { board[tr+s][tc+s]=t; TileBoard(tr+s, tc+s, tr+s, tc+s, s); } } int main() { int size; cin>>size; //输入棋盘大小 int tr, tc, dr, dc; tr=tc=size; cin>>dr>>dc; //输入残缺点 board[dr][dc]=0; TileBoard(0, 0, dr, dc, size); for(int i=0; i 
          

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值