Uva 129 Krypton Factor(困难的串)
来源:互联网 发布:沈阳数据恢复公司 编辑:程序博客网 时间:2024/05/22 09:59
运用回溯法,是否包含两个相邻的的字串只需要判断当前串的后缀
代码如下:
#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <string>#include <cstdio> #include <climits>#include <cmath> using namespace std;int n,l,cnt,times=0;int A[99];int dfs(int cur){ //回溯法if(cnt++==n){int times=0;for(int i=0;i<cur;i++){printf("%c",'A'+A[i]-1); times++;if(times%4==0){if(times<cur&×!=64) printf(" ");}if(times==64&&cur>64){printf("\n");}}printf("\n%d\n",cur);return 0;} for(int i=0;i<l;i++){ int OK=1;A[cur]=i+1; for(int j=1;j*2<=cur+1;j++){int equal=1;for(int z=0;z<j;z++)if(A[cur-z]!=A[cur-z-j]){equal=0;break;}if(equal){OK=0;break;}}if(OK) if(!dfs(cur+1)) return 0;}return 1;}int main(){#ifdef DIDfreopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);#endifwhile(scanf("%d%d",&n,&l)!=EOF&&(n||l)){cnt=0;memset(A,0,sizeof(A)); int kk=dfs(0);} return 0;}
0 0
- 困难的串(Krypton Factor,UVa 129)
- Uva 129 Krypton Factor(困难的串)
- 困难的串(Krypton Factor,UVa 129)
- UVA-129 Krypton Factor 困难的串
- UVA 129 困难的串Krypton Factor (回溯法)
- 困难的串(Krypton Factor,UVa 129)
- 例题7-5 UVA 129 Krypton Factor (困难的串,搜索)
- 例题7-5 困难的串(Krypton Factor, UVa 129)
- 困难的串(Krypton Factor,UVa129)
- uva 129 Krypton Factor
- uva 129 - Krypton Factor
- UVa 129 Krypton Factor
- UVA - 129 Krypton Factor
- UVa-129 - Krypton Factor
- UVa - 129 - Krypton Factor
- UVA - 129 Krypton Factor
- uva 129 - Krypton Factor
- uva 129 - Krypton Factor
- 家用路由器的选择困境
- Struts.xml命名空间配置
- cocoapods版本更新遇到的一系列问题
- ubuntu 的使用(五)—— 桌面(desktop)
- git-canal:学习记录1
- Uva 129 Krypton Factor(困难的串)
- 使用DOSBox在x64位下搭建汇编环境win7、8、10
- C++第六次实验:数组操作
- JavaScript使用Sqlite数据库
- 《jQuery从入门到精通》第二节 开始使用jQuery(一)
- MediaWiki安装插件 ——以CategoryTree为例
- 计算机组成.就是它在运算.处理器CPU
- LeetCode-17.Letter Combinations of a Phone Number
- No such filter: 'drawtext'