2013年2月26日

uva10001 - Garden of Eden

摘要: 题意不好理解,参考了人家的代码才看懂的题意,就是用某种编译方式,检测所给字符串是否合理,即求它的原串。两者长度一样,只不过新得的串是根据所给编译方式和左邻右舍的值来求得的。对于编译方式 rule:0其意思为:0 0 0 -->00 0 1 -->00 1 0 -->00 1 1 -->0......通俗来讲就是对于编译方式k,先把k转化为八位二进制串,8 -->0 0 0 0 1 0 0 0.。 用八位二进制串中的每个字符分别对应{0,0,0},{0,0,1},{0,1,0},{0,1,1},{1,0,0},{1,0,1},{1,1,0},{1,1,1}跟详细的解 阅读全文
posted @ 2013-02-26 15:53 Primo... 阅读(151) 评论(0) 推荐(0)

vua167 - The Sultan's Successors

摘要: 很简单的八皇后题目。单纯递归筛选。。。。分别用y-x, x+y,来标识对角线,这在刘汝佳书上都有讲的。代码如下:#include int chess[8][8], lu_to_rd[14], ru_to_ld[14], l[8], max; //lu_to_rd 表示主对角线(left&up to right&down) //同理,ru_to_ld标识副对角线 void dfs(int cur, int sum) { if(cur==8) { m... 阅读全文
posted @ 2013-02-26 12:06 Primo... 阅读(157) 评论(0) 推荐(0)

uva165 - stamps(邮票)

摘要: 不得不说这道题,对我来说很难,开始的时候甚至连题意都弄不清,看了人家的代码,看懂了第一种方法,第一种方法很好理解,但是比较耗时。因为它没次递归都得算出那些值有可能出现。就是每次递归中都得包含调用递归。代码如下:#include #include int stamp[10], maxstamp[10], ans[10], max, h, k; void is_visit(int n, int cur, int sum, int *vis) { if(cur==h) return; for(int i = 0; i %3d\n",max); } return 0... 阅读全文
posted @ 2013-02-26 11:07 Primo... 阅读(233) 评论(0) 推荐(0)