UVa 729: The Hamming Distance Problem
来源:互联网 发布:js中json删除指定元素 编辑:程序博客网 时间:2024/05/22 11:40
这道题只要枚举出所有情况就可以了。
从最左边一位开始分别讨论为0和为1 两种情况,向右递归。
我的解题代码如下:
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <string>using namespace std;int s[16];int T,N,H;void f(int curn, int curh){if(curn==N && curh==H){for(int i=0; i<N; i++) cout << s[i]; cout << endl;return ;}if((N-curn) > (H-curh)){s[curn]=0;f(curn+1,curh);}if(curh < H){s[curn]=1;f(curn+1,curh+1);}}int main(){cin >> T;while(T--){cin >> N >> H;memset(s,0,sizeof(s));f(0,0);if(T) cout << endl;}return 0;}
- UVa 729 The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem
- UVA 729 - The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem
- uva 729 - The Hamming Distance Problem
- uva 729 The Hamming Distance Problem
- UVa 729: The Hamming Distance Problem
- uva 729 The Hamming Distance Problem
- uva - 729 - The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem
- uva 729 - The Hamming Distance Problem
- uva 729 - The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem 排列组合
- UVa 729 - The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem
- UVA 729 - The Hamming Distance Problem
- UVa-729-The Hamming Distance Problem
- UVA - 729 The Hamming Distance Problem
- VS2010 c#利用GDAL创建金字塔文件(金字塔文件包含在文件内部)
- POJ-1823-Hotel
- ubuntu编译android源码
- 黑马程序员——Java学习笔记(四) .
- 对象的动态和静态构造创建的区别
- UVa 729: The Hamming Distance Problem
- HDU 3939 毕达哥拉斯三元组
- HTML,CSS,HTTP
- Myeclipse修改Java web项目名称
- Java对象的强、软、弱和虚引用
- log4j配置
- EhCache使用详细介绍
- intent 的带参传递
- 数据库日志无法归档,超出了恢复文件数的限制解决方案