摘要: http://poj.org/problem?id=1564http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1711 简单深搜,主要是这一句 if(!vis[i]&&data[i]<=sum&&(data[i]!=data[i-1]||i==pos))。 确保两个连续的相同的数只有一次机会进入ans[],避免了结果的重复。code:#include<cstdio>#include<cstring>intdata[15];intans[15];boolvis[1 阅读全文
posted @ 2012-03-11 21:13 追逐. 阅读(187) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2965 16个位置分别有两个状态,用一个16位的二进制表示,对beg按位或运算得到初始状态,bfs中,用只包含0,1的16进制数实现翻转操作。 剩下的就是单纯的bfs了。code:#include<iostream>#include<cstdio>#include<cstring>usingnamespacestd;intdir[16]={0x111f,0x222f,0x444f,0x888f,0x11f1,0x22f2,0x44f4,0x88f8,0x1f11,0x2f22,0x4f44,0x8f88, 阅读全文
posted @ 2012-03-11 19:57 追逐. 阅读(209) 评论(0) 推荐(0) 编辑