4*4摩天大楼问题

本文探讨了4*4网格上的摩天大楼拼图问题,要求每行和每列的楼层数唯一。通过举例说明解题思路,并提供了一种使用穷举法的C语言实现,尽管效率不高,但能有效找到解决方案。未来计划探索更优化的算法方法。
摘要由CSDN通过智能技术生成

给出4*4的网格平面,要求在这个16个格子里面放入楼层分别是1、2、3、4层高的楼栋;

要求每行以及每列的1~4层楼必须且只能出现一次;

给出条件是从每个方向上所能看到的不被遮挡的楼栋数目;

Example: 

To understand how the puzzle works, this is an example of a row with 2 clues. Seen from the left side there are 4 buildings visible while seen from the right side only 1: 

 

There is only one way in which the skyscrapers can be placed. From left-to-right all four buildings must be visible and no building may hide behind another building: 


Example of a 4 by 4 puzzle with the solution: 
 

代码(我这个是用穷举的方法来做的,先算出4!一共24种组合,然后依次遍历,其实比较笨,应该有更聪明的方法,以后有空了想想):

typedef struct _AssNode{
	int Valuegroup[4];
	int LeftViewCnt;
	int RightViewCnt;
}As
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值