数据结构与算法-递归(回溯法)

版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/Yvken_Zh/article/details/80807663

递归:程序调用自身的编程技巧。具体点说一个函数自己调用自己就是递归。

编程中如果要用到递归去解决一个问题,首先要考虑的是递归的停止条件是什么?如果忽略掉这一点,你的程序就会一直递归递归,直到栈溢出,弹出来一个框框。递归何时停止,这是我们在写一个函数之前首要考虑的地方。

可以把递归看成一个栈,每一次的递归就好像是压栈,弹出栈的时候就好像是遇到了递归的停止条件,返回条件。返回了上一级的调用函数。二叉树的非递归遍历就是可以通过栈完成,链表的逆序打印可以递归,也可以用栈,这个思想是一样的。

理解递归一定要明白有一个返回的过程,这个函数里面的任务做完了,没有什么好做的了,就返回了调用该函数的部分。

关于递归 又很多例题,求斐波拉基数列,当然也可以循环,字符串的全排列,经典的八皇后问题等等。

回溯法的精髓就是递归,正是有递归这样子,才可以解决图的一些问题,关于一些路径的问题。

我初次接触递归的时候,是以汉诺塔例题,我的老师让我们拿出很多了纸片,每张纸片上写着当前函数中各个变量信息,每递归一次就再拿出一张新的纸片,表示这是一个新的场景,这让我对递归有很深的印象吗,后来自己遇到看不懂的递归代码,也仿照着在纸上画出来。

总而言之,要想熟练的掌握递归用法,进一步解决问题,还是要从简单的练习做起,弄清楚递归每一步的流程,在哪里返回上一层调用了,这是尤为重要的。

在一些场景下不允许使用循环的时候,就可以通过递归来解决。在牛客网刷题剑指offer的时候,就有一道题要求是,不得使用判断循环语句求1-n的和,就是用递归加短路运算解决掉了。

求斐波拉基数列

兔子数列{1,1,2,3,5,8,。。。。。}的递归实现和求和的递归实现是大同小异的,这也是最简单的递归例题。

这种例题属于单次递归,只有一个分支的递归,还是比较容易理解的。

int Fibonacci(int n) {
  if(n <= 1) {
    return 1;
  }

  return Fibonacci(n- 1) + Fibonacci(n - 2);;
}

全排列问题 一个字符串的所有排列情况

void ArrangeMent(int n, char* str) {
	int str_length = strlen(str);
	int i;

	if(n >= str_length) {
		puts(str);
	}else {
		for(i = n; i < str_length; i++) {
		    if(i!=n && str[i]==str[n]) {//有重复字符时,跳过
                        continue;
                    }
		swapChar(str + i, str + n);
		ArrangeMent(n + 1, str); 
		swapChar(str + i, str + n);
	}
    }
}

结果大概是这样:以abcd为例

求二叉树的高度

//递归求二叉树的高度
int PostTreeDepth(BinaryTree *root) {
	int h_left;
	int h_right;

	if(root == NULL) {
		return 0;
	}else {
		h_left = PostTreeDepth(root->LeftChild);
		h_right = PostTreeDepth(root->RightChild);

		return (h_left > h_right ? h_left : h_right) + 1;
	}
}

 

这个递归当时自己画了一张图 还是比较容易理解的,这大概是一个二叉分路的递归,一个函数里面 有两次的递归调用 。画出来的图里面有好多了二叉

八皇后问题

还是通过递归,循环的递归,这里就有回溯法的体现,在八皇后的代码里面有判断当前位置是否安全的函数,isSafe,判断这个位置的上面,左上,右上是否已经存在皇后,此位置是否安全。主要的函数方法就是两个,一个是递归,一个是判断是够此位置是否安全。

void EightQueen(int (*chess)[EIGHT], int row) {
	int col;

	if(row >= EIGHT) {
		showEightQueen(chess);
		return;
	}

	for(col = 0; col < EIGHT; col++) {  //这里是循环 8次的递归 是对于列
		if(isSafe(chess, row, col)) {
			chess[row][col] = 1;
			EightQueen(chess, row + 1); //递归到下一行
			chess[row][col] = 0;
		}
	}

}
boolean isSafe(int (*chess)[EIGHT], int row, int col) {
	int i;
	int j;

//The upper left
	for(i = row - 1, j = col - 1; i >= 0 && j >= 0; i--, j--) {
		if(chess[i][j]) {
			return false;
		}
	}
//Just above
	for(i = row - 1, j = col; i >= 0; i--) {
		if(chess[i][j]) {
			return false;
		}
	}
//The upper right

	for(i = row - 1, j = col + 1; i >= 0 && j < EIGHT; i--, j++) {
		if(chess[i][j]) {
			return false;
		}
	}

	return true;
}

八皇后的92种解

The 1 solution is :
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  

The 2 solution is :
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 3 solution is :
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  

The 4 solution is :
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  

The 5 solution is :
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  

The 6 solution is :
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  

The 7 solution is :
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  

The 8 solution is :
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 9 solution is :
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  

The 10 solution is :
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  

The 11 solution is :
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  

The 12 solution is :
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  

The 13 solution is :
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  

The 14 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  

The 15 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  

The 16 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  

The 17 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 18 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  

The 19 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  

The 20 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  

The 21 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  

The 22 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  

The 23 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  

The 24 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  

The 25 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  

The 26 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  

The 27 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 28 solution is :
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 29 solution is :
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 30 solution is :
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  

The 31 solution is :
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  

The 32 solution is :
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 33 solution is :
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  

The 34 solution is :
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  

The 35 solution is :
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 36 solution is :
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  

The 37 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  

The 38 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 39 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  

The 40 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  

The 41 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 42 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  

The 43 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  

The 44 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  

The 45 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  

The 46 solution is :
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 47 solution is :
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  

The 48 solution is :
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 49 solution is :
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  

The 50 solution is :
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  

The 51 solution is :
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  

The 52 solution is :
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  

The 53 solution is :
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 54 solution is :
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  

The 55 solution is :
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  

The 56 solution is :
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  

The 57 solution is :
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  

The 58 solution is :
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  

The 59 solution is :
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 60 solution is :
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  

The 61 solution is :
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  

The 62 solution is :
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  

The 63 solution is :
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  

The 64 solution is :
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  

The 65 solution is :
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  

The 66 solution is :
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  

The 67 solution is :
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  

The 68 solution is :
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  

The 69 solution is :
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  

The 70 solution is :
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  

The 71 solution is :
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  

The 72 solution is :
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  

The 73 solution is :
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 74 solution is :
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  

The 75 solution is :
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 76 solution is :
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  

The 77 solution is :
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  

The 78 solution is :
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  

The 79 solution is :
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  

The 80 solution is :
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  

The 81 solution is :
0  0  0  0  0  0  1  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 82 solution is :
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 83 solution is :
0  0  0  0  0  0  1  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  

The 84 solution is :
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  1  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  

The 85 solution is :
0  0  0  0  0  0  1  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  1  0  0  0  0  

The 86 solution is :
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  0  1  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 87 solution is :
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  0  1  
0  0  0  0  0  1  0  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  1  0  0  0  

The 88 solution is :
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  

The 89 solution is :
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  

The 90 solution is :
0  0  0  0  0  0  0  1  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  
0  0  0  0  0  1  0  0  

The 91 solution is :
0  0  0  0  0  0  0  1  
0  0  1  0  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  1  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  1  0  0  0  0  

The 92 solution is :
0  0  0  0  0  0  0  1  
0  0  0  1  0  0  0  0  
1  0  0  0  0  0  0  0  
0  0  1  0  0  0  0  0  
0  0  0  0  0  1  0  0  
0  1  0  0  0  0  0  0  
0  0  0  0  0  0  1  0  
0  0  0  0  1  0  0  0  

展开阅读全文

没有更多推荐了,返回首页