UVA 129(p195)----Krypton Factor
2016-02-25 22:29
351 查看
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int maxn=100; int a[maxn]; int n,l,cnt; int solve(int dep) { if(cnt++==n) { for(int i=0; i<dep; i++) { if(i%64==0&&i) printf("\n"); else if(i%4==0&&i) printf(" "); printf("%c",'A'+a[i]); } printf("\n%d\n",dep); return 0; } for(int i=0; i<l; i++) { a[dep]=i; int flag=1; for(int j=1; 2*j<=dep+1; j++) { int Equal=1; for(int k=0; k<j; k++) if(a[dep-k]!=a[dep-j-k]) { Equal=0; break; } if(Equal) { flag=0; break; } } if(flag) if(!solve(dep+1)) return 0; } return 1; } int main() { while(scanf("%d%d",&n,&l)==2&&n) { cnt=0; solve(0); } return 0; }题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=65
相关文章推荐
- Linux Framebuffer驱动剖析之一—软件需求
- Linux Framebuffer驱动剖析之一—软件需求
- union和struct类型的大小计算
- 【解决方法】友盟分享 已安装QQ,但总提示“没有安装手机QQ客户端”
- Java String详解
- Linux Framebuffer驱动剖析之一—软件需求
- Struts2 自定义下拉框标签Tag
- Struts2 自定义下拉框标签Tag
- Struts2 自定义下拉框标签Tag
- UVA 120(p236)----Stacks of Flapjacks
- jquery json ajax -2
- leetcode-33-Search in Rotated Sorted Array
- 《leetCode》:Convert Sorted List to Binary Search Tree
- leetcode 316. Remove Duplicate Letters
- Sam版Matlab粒子群PSO工具已经更新
- 效率:条款19 了解临时对象的来源
- android书籍
- [Leetcode]214. Shortest Palindrome@python
- windows下安装zend框架
- UVA 116(p270)----Unidirectional TSP