标签:http io ar for sp html c amp size
题目来源:HDU 2894 DeBruijin
题意:
思路:
#include <cstdio> #include <cstring> using namespace std; int vis[5000], ans[5000]; int len, n; void dfs(int u) { int v = ((u<<1)&((1<<n)-1)); if(!vis[v]) { vis[v] = 1; dfs(v); ans[len++] = 0; } if(!vis[v+1]) { vis[v+1] = 1; dfs(v+1); ans[len++] = 1; } } int main() { while(scanf("%d", &n) != EOF) { memset(vis, 0, sizeof(vis)); len = 0; dfs(0); printf("%d ", (1<<n)); for(int i = 1; i < n; i++) printf("0"); for(int i = len-1; i >= n-1; i--) printf("%d", ans[i]); puts(""); } return 0; }
标签:http io ar for sp html c amp size
原文地址:http://blog.csdn.net/u011686226/article/details/39208457