ZOJ1089(dfs)
2016-05-24 19:53
274 查看
#include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #include <string> #include <iostream> using namespace std; int a[22], b[22]; int n; void print() { for(int i = 1; i <= 6; i++) { printf("%d%c", a[b[i]], (i == 6) ? '\n' : ' '); } } void dfs(int x, int st) { b[x] = st; if(x > 6) { print(); return; } if(st > n) return; dfs(x+1, st+1); dfs(x, st+1); } int main() { int k = 0; while(scanf("%d", &n) && n) { k++; if(k != 1) { printf("\n"); } for(int i = 1; i <= n; i++) { scanf("%d", &a[i]); } for(int i = 1; i <= 6; i++) { b[i] = i; } dfs(1, 1); } return 0; }
相关文章推荐
- Best Time to Buy and Sell Stock
- 图片缓存之内存缓存技术LruCache,软引用
- 方法的类型提示
- Android SERVICE后台服务进程的守护
- 工具类系列-ClazzReflectUtil
- 工具类系列-JavaBean2Map
- Cortex-A8处理器memcpy的优化方案
- Android 使用intent打开手机自带应用播放视频,音频,文档,还有打开应用市场
- 构建之法阅读笔记06
- LeetCode题解——Verify Preorder Serialization of a Binary Tree
- Android 双进程Service常驻后台,无惧“一键清理”
- brew install php55 报错 clang: error
- Microsoft.AspNet.Identity.EntityFramework 源码
- BZOJ 1614 Telephone Lines架设电话线
- JavaScript的bom对象
- 蓝桥杯----剪格子
- CentOS6.5 64位GCC从4.4.2升级到4.8.5实录
- 二分搜索与一般搜索
- Android ndk cannot locate symbol "atof" referenced by的解决方法
- Regular Expression Matching,regex,正则表达式匹配,利用动态规划