算法回顾--N皇后问题简单回顾
前言
最近学习的过程中,不知道哪门子的思维发散,突然又遇见皇后问题了,于是乎老调重弹,心里琢磨,虽然思路大家都容易懂,哪怕是最简单的野蛮回溯法,说着简单,但是如果非得编码实现?我可以一次性写出来OK的代码吗?我对此表示疑问,于是乎动手写代码,发现写此类算法问题,最重要的是边界条件的判断。这里说明一下,这篇纯属练手,不考虑算法效率,只是为了实现,为了练习最暴力野蛮的回溯,说白了,就是怎样简单粗暴的玩弄for和while这些个玩意!
实现
本人比较懒,所以懒得搞二维数组来存储皇后坐标,其实用二维数组来存储,然后根据行列来遍历和匹配,确实效率高了不少,但是,我在这里仅仅只是练习回溯的思想,所以只是使用简单的数组来存储N*N个数,比如8皇后问题,我就用数组来存储 {1,2,3,,,,,,,,,,64},然后使用queens数组存储安全的皇后
代码
/// <summary>
/// 皇后算法非递归实现,主要思想如下:
/// 初始化皇后备选列表为空(安全),将所有坐标的棋子尝试放入
/// 如果符合安全,则放入(如果数目达到则保留输出),如果不安全则跳过继续搜索
/// 如果搜索到结尾依然未搜到,则循环向上回溯到上一次解的下一个继续
/// </summary>
public class Queen
{
// 矩阵维度
int size;
// 从1编号,存放所有整数
int[] array;
int count; public Queen()
: this(4)
{
} public Queen(int s)
{
this.size = s;
InitList();
} private void InitList()
{
count = size * size;
array = new int[count];
for (int i = 0; i < count; i++)
{
array[i] = i + 1;
}
} public void PrintQueenResult()
{
List<int> queens = new List<int>(); // 记录探测索引
int tryIndex = 0;
// 记录最后一次皇后解
int lastQueen = 0;
// 记录皇后总数
int queenCount = 0;
// 记录所有全皇后解个数
int solutions = 0;
while (true)
{
// 探测元素
int tryItem = array[tryIndex]; // 如果探测到最后一个元素,并且皇后已经回溯为空
// 表示回溯已经全部完成,返回
if (tryItem == array[count - 1] && queenCount == 0)
break; // 找到安全的皇后
if (IsSafe(queens, tryItem))
{
queens.Add(tryItem);
// 皇后数加1
queenCount++;
// 记录最后一次放置的皇后
lastQueen = tryItem; // 如果皇后获取足够,输出
if (queenCount == size)
{
Console.WriteLine("找到皇后排列:{0}",
string.Join(",", queens));
solutions++;
}
}
else
{
if (tryIndex < count - 1)
{
// 如果不安全,还未搜索结束,继续搜索
tryIndex++;
}
else
{
// 如果不安全,但搜索结束,则回溯
while (tryIndex >= count - 1)
{
queens.Remove(lastQueen);
queenCount--;
tryIndex = lastQueen; // 如果回溯完毕则跳出
if (queenCount == 0)
break; lastQueen = queens[queenCount - 1];
}
}
}
} Console.WriteLine("全部解个数为:{0}", solutions);
} private bool IsSafe(List<int> list, int target)
{
if (list == null || list.Count == 0)
return true;
return list.All(d => !IsDangerous(d, target));
} private bool IsDangerous(int a, int b)
{
int rowA = (a - 1) / size + 1;
int rowB = (b - 1) / size + 1;
int colA = (a - 1) % size + 1;
int colB = (b - 1) % size + 1; if (a == b) return true;
if (rowA == rowB) return true;
if (colA == colB) return true;
if (Math.Abs(rowA - rowB) == Math.Abs(colA - colB))
return true; return false;
} private int Pop(List<int> list)
{
int last = list[list.Count - 1];
list.Remove(last);
return last;
} private int Peek(List<int> list)
{
return list[list.Count - 1];
}
}
测试
八皇后测试代码:Queen q = new Queen(8); q.PrintQueenResult();
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAacAAAGACAIAAACGJDpBAAAgAElEQVR4nO2c0ZEEOW5E20VZIHdkxlkgG9qB80lfN0GRBJgAwarhznsxsdHNApJJFsGZvZXw+de//5sffvjh5+/8fF53wA8//PDz5A+3Hj/88PO3frj1+OGHn7/1w63HDz/8/K0fbj1++OHnb/1w6/HDDz9/62d+6/3P//4XP/zww88/8se89T7/4fv9fhp+vnbjIk5WTnCZ/ph/ALiD9K03fraw0pXxJc5cvv8xeMc/AFxD1a1nxSwfidelFW+vbOE/ZFJ5BAB3sHPrTfH/4JreerqOYmAaP16UztXpjHDrAVyPdetZf3lZl0j71Pk8vVAspobFe8eSWt5fzqr12ZeuQimhcWfSacrv0Vm+el9QH7cmHY9K1JIfnFgaHEH/W295Asbxr3BrRKt6PKb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9kI2d0/xtsB5Ng8eKsqR0Hd//OR1nH6xxS2eaFd2fQj/TeN8PvAP99dIePkW/w6uKAZ27dOA16K83fbr0DwC3Qn89XzMUAAAXsPw33Bal7KNXw85VIuYmLrhQGADcRPmtNw1b/nuoFenPKD51PviC3HoA/0D0W2/5P2w5/1ub9S/Cy6vQn84P6GIsD9OUZRgA3Ip4623eBdYtFh3P+RkDnD8nufUA/uEot9701piqLS+v6Z0yzXL+lFP8JP7wVCbawblnp+MAcITE/2+GOD5eLtOR6JUU8jO9QK0prIuy5FZq05XPAHAK5f9yxar/0JXRCrZZn9mdOH510pdfuw/f1cVqPeLWA/gnsOw+0DIdUQo1dOtZl2DIj3W1TefyPTsjOsrtxq0H8AQn/i9X/MTuc4szmPZj3S/LdP/2TOCviysP4CFqb73vwJho/eWl/xWm+BmdWPMulR1LiauKKw/gZcReyv4l0gZPv+q3niU1RbmFl970xEO3HlcewKOU/603/fpT2NOCb69R8XpV/PjXXEJ2/27yrzyuP4AneOzWm6Yf/Vuvu1CseXXNzb/1ppe4fsUDQA3P/+96o9qhW6+1NE20xvXpuKcA7sPvr6fQqllflb+qTtx6Pw7bSOXzOAu3G8A/hNDfemmWf1UtL1BRdimo/90XNQMAd/DMrQcA8Fvg1gOAvwW3HgD8Lbj1AOBvwa0HAH8Lbj0A+Ftw6wHA34JbDwD+FP8Hd2V9WDawAjoAAAAASUVORK5CYII=" alt="" />
结语
脑子不练会生锈,还是要经常做做这些最基础的东西,把不习惯变成习惯,慢慢来,不早了,先睡了
算法回顾--N皇后问题简单回顾的更多相关文章
- 数论算法 剩余系相关 学习笔记 (基础回顾,(ex)CRT,(ex)lucas,(ex)BSGS,原根与指标入门,高次剩余,Miller_Rabin+Pollard_Rho)
注:转载本文须标明出处. 原文链接https://www.cnblogs.com/zhouzhendong/p/Number-theory.html 数论算法 剩余系相关 学习笔记 (基础回顾,(ex ...
- Android混淆、反编译以及反破解的简单回顾
=========================================================================虽然反编译很简单,也没下面说的那么复杂,不过还是转了过 ...
- 中国2017 Google 开发者大会第二天简单回顾
昨天早晨发布了第一天的开发者大会回顾文章后,就匆匆忙忙赶去会场继续享受高科技的盛宴,接下来简单回顾一下第二天的大会参与情况. 昨天早晨下着小雨,并带着微风,在外面还是挺冷的,这里不得不给工作人员点个赞 ...
- 中国2017 Google 开发者大会第一天简单回顾
昨天有幸参加了中国2017 Google 开发者大会,在这第一天就收获满满,昨天太忙了,今天早晨来一起简单回顾一下,可以让没有参加的童鞋们感受一下现场的温度. 早早就来到了会议现场,外面看不出什么特别 ...
- 蓝桥杯 算法提高 8皇后·改 -- DFS 回溯
算法提高 8皇后·改 时间限制:1.0s 内存限制:256.0MB 问题描述 规则同8皇后问题,但是棋盘上每格都有一个数字,要求八皇后所在格子数字之和最大. 输入格式 一个8*8 ...
- Java实现蓝桥杯 算法提高 八皇后 改
**算法提高 8皇后·改** 时间限制:1.0s 内存限制:256.0MB 提交此题 问题描述 规则同8皇后问题,但是棋盘上每格都有一个数字,要求八皇后所在格子数字之和最大. 输入格式 一个8*8的棋 ...
- 【数据结构与算法】Java制作一个简单数组类
bobo老师的玩转算法系列–玩转数据结构 简单记录 文章目录 不要小瞧数组 - 制作一个数组类 1 .使用Java中的数组 数组基础 简单使用 2.二次封装属于我们自己的数组 数组基础 制作属于我们自 ...
- KMP算法简单回顾
前言 虽从事企业应用的设计与开发,闲暇之时,还是偶尔涉猎数学和算法的东西,本篇根据个人角度来写一点关于KMP串匹配的东西,一方面向伟人致敬,另一方面也是练练手,头脑风暴.我在自娱自乐,路过的朋友别太认 ...
- kafka简单回顾
先说说遇到的坑 回顾下kafka topic:生产组:P0\P1----P14 一个消费组:c0 c1 c2 依据Consumer的负载均衡分配 消费顺序"c0:p0-p4 c1:p5-p9 ...
随机推荐
- NSIS:使用nsWindows.nsh头文件调整窗体大小
原文 NSIS:使用nsWindows.nsh头文件调整窗体大小 此方法只能简单实现调整窗体大小,但不完美,调整后窗体上其他的控件都需要调整大小或位置,比较麻烦,轻狂不建议使用呵! ;加头文件!inc ...
- 续x奇数倍(n+2*x)暴力算法是冠军的算法结合数量
// 续6单a,a+2,a+4,a+6,a+8,a+10是共同的数.最低要求a // 暴力解决方案 首先对结果,后面将代码粘贴: 1次连续n=9,连续值个数: 1;耗时: 0ms,总计: 0ms 2次 ...
- HDU 1198 Farm Irrigation (并检查集合 和 dfs两种实现)
Farm Irrigation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 【iOS开展-94】xcode6如何使用GIT以及如何添加太老项目GIT特征?
(1)对于一个新项目:如何使用GIT?在新项目的过程,例如,您可以选择下面的复选框. (2)针对老项目,加入GIT功能. --在终端.cd到项目文件夹 --然后输入git init,初始化一个.git ...
- 【转】细说 Form (表单)
阅读目录 开始 简单的表单,简单的处理方式 表单提交,成功控件 多提交按钮的表单 上传文件的表单 MVC Controller中多个自定义类型的传入参数 F5刷新问题并不是WebForms的错 以Aj ...
- CSharp设计模式读书笔记(15):命令模式(学习难度:★★★☆☆,使用频率:★★★★☆)
命令模式(Command Pattern):将一个请求封装为一个对象,从而让我们可用不同的请求对客户进行参数化:对请求排队或者记录请求日志,以及支持可撤销的操作.命令模式是一种对象行为型模式,其别名为 ...
- cocos2dx 3.0正式版 于mac在新建项目
下载cocos2dx 3.0正式版,和安装python2.7.*版本号. 加入cocos命令: mac下: 在cocos2d-x\tools\cocos2d-console\bin文件夹下.执行ins ...
- Net开源网络爬虫
转载.Net开源网络爬虫Abot介绍 .Net中也有很多很多开源的爬虫工具,abot就是其中之一.Abot是一个开源的.net爬虫,速度快,易于使用和扩展.项目的地址是https://code.goo ...
- jQuery组织您钞四----jQuery操作DOM
一.采用jQuery创建节点 节点是DOM基础设施.依据DOM产品规格,Node是一个很宽泛的概念,包含元素.属性.正文.档..实际开发过程中,要创建动态内容,主要操作的节点包括元素. 属性和文本. ...
- 2014牡丹江区域赛H(特里)ZOJ3826
Hierarchical Notation Time Limit: 2 Seconds Memory Limit: 131072 KB In Marjar University, stude ...