摘要: 转自 http://plussai.iteye.com/blog/1161889题目中需要对0-8九个数的全排列计数(字典序),来完成一张对于的HASH表,显然状态空间中共有9!个状态,可以看成一颗树,第一层9个子节点,第二层每个节点8个子节点,第三层每个节点7个子节点,以此类推。 那么对于某中特定的排列,要求它的字典计数,只需求出每一层在该点之后的节点个数乘以该层对应的DP项。。。int dp[10]={1,1,2,6,24,120,720,5040,40320,362880}; int getHash(int code[9]) { int sum=0; bool flag[9]; i... 阅读全文
posted @ 2011-10-08 17:49 dbstone 阅读(375) 评论(0) 推荐(0)
摘要: 转自 http://blog.csdn.net/wmbol/article/details/5546903/* * 1091.cpp * * Created on: Apr 29, 2010 * Author: wyy * */ #include<cstdio> #include<queue> using namespace std; struct point { int x, y, num; }; int dx[8] = {1, 1, -1, -1, 2, -2, 2, -2}; int dy[8] = {2, -2, 2, -2, 1, 1, -1, -1};... 阅读全文
posted @ 2011-10-08 13:30 dbstone 阅读(197) 评论(0) 推荐(0)
摘要: #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<queue> 5 6 using namespace std; 7 8 queue<int>q; 9 int main() 10 { 11 int a, x, b, y; 12 int visit[9][9]; 13 char c1, c2, r1, r2; 14 15 while(cin>>c1>>r1>>c2>>r2) 16 { 17 memset 阅读全文
posted @ 2011-10-08 01:20 dbstone 阅读(279) 评论(0) 推荐(0)