最近迷上了玩数独。每次我玩上了什么游戏,总想自己也做一个。于是就自己写了一个数独的生成算法。
最终的成果是这样的:
程序能很快速的生成各种随机的数独数组,快到什么程度呢?以每次生成或者回溯一个格子的数字算一步,我的算法每次只需要200或者300多步就能生成一个完整的可解数独。快的时候,80多步就生成了,基本感觉不到生成的时间消耗。这样的效率,对比了网上的一些数独生成算法,我个人感觉已经很高...
分类:
编程语言 时间:
2015-01-30 21:11:22
阅读次数:
206
uva 539 The Settlers of Catan
Within Settlers of Catan, the 1995 German game of the year, players attempt to dominate an island by building roads, settlements and cities across its uncharted wilder...
分类:
其他好文 时间:
2015-01-29 12:45:04
阅读次数:
149
uva 301 Transportation
Ruratania is just entering capitalism and is establishing new enterprising activities in many fields including transport. The transportation company TransRuratania is sta...
分类:
其他好文 时间:
2015-01-29 12:44:36
阅读次数:
150
题目链接:Regular Expression Matching
Implement regular expression matching with support for '.' and '*'.
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
The match...
分类:
其他好文 时间:
2015-01-28 21:29:00
阅读次数:
318
原题地址依次枚举起始点,DFS+回溯代码: 1 bool dfs(vector > &board, int r, int c, string word) { 2 int m = board.size(); 3 int n = board[0].size(); 4 int dir[4][2...
分类:
其他好文 时间:
2015-01-28 17:32:06
阅读次数:
141
回溯题型主要有两种,一种是子集生成问题:就是给你一个集合,求它的子集,这种主要是通过选或不选当前元素来枚举所有情况
另一种是枚举全排列。每一次确定当前的选择,则标记,这样下一次的选择就减少了一个。...
分类:
其他好文 时间:
2015-01-28 09:48:16
阅读次数:
173
一:问题描述本题题意大致是说:给出一棵多叉树,每个节点的任意两个子节点都有左右之分。从根节点开始,每次尽量往左边走。走不通了就回溯,把遇到的字母顺次记录下来,可以得到一个序列。现在给定一个序列,要求满足条件的多叉树的数目。二:题目分析我们可以分析对于这个序列而言一定是对称序列,那么对于序列S而言,我...
分类:
其他好文 时间:
2015-01-27 21:37:24
阅读次数:
110
uva 639 Don't Get Rooked
In chess, the rook is a piece that can move any number of squares vertically or horizontally. In this problem we will consider small chess boards (at most 44)
tha...
分类:
其他好文 时间:
2015-01-27 18:36:48
阅读次数:
195
这个题题意是给你价值1-6的珠宝个数输出能否平分为两份(如果平分为三分就不知道怎么做了……)主要是用回溯DFS,但是要剪枝,对200取模……!!(很重要……)代码……#include #include #include #include #include #include #include usin...
分类:
其他好文 时间:
2015-01-27 10:53:28
阅读次数:
105