题意:
莫名其妙 看不懂。。只能靠别人的题意混日子
a完就懂了 就是 POJ1392 不求第k个了 直接输出这个路径
emm 。。。就改了一下那个代码
#include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <cctype> #include <set> #include <vector> #include <stack> #include <queue> #include <algorithm> #include <cmath> #include <bitset> #define rap(i, a, n) for(int i=a; i<=n; i++) #define rep(i, a, n) for(int i=a; i<n; i++) #define lap(i, a, n) for(int i=n; i>=a; i--) #define lep(i, a, n) for(int i=n; i>a; i--) #define rd(a) scanf("%d", &a) #define rlld(a) scanf("%lld", &a) #define rc(a) scanf("%c", &a) #define rs(a) scanf("%s", a) #define pd(a) printf("%d ", a); #define plld(a) printf("%lld ", a); #define pc(a) printf("%c ", a); #define ps(a) printf("%s ", a); #define MOD 2018 #define LL long long #define ULL unsigned long long #define Pair pair<int, int> #define mem(a, b) memset(a, b, sizeof(a)) #define _ ios_base::sync_with_stdio(0),cin.tie(0) //freopen("1.txt", "r", stdin); using namespace std; const int maxn = 16, INF = 0x7fffffff, LL_INF = 0x7fffffffffffffff; int f[1 << maxn], vis[1 << maxn][2], stk[1 << maxn]; int n, k, tot; void fleury(int u) { for(int i = 0; i <= 1; i++) { if(!vis[u][i]) { vis[u][i] = 1; fleury(((u << 1) + i) % f[n - 1]); stk[tot++] = i; } } } int main() { f[0] = 1; for(int i = 1; i < 16; i++) f[i] = f[i-1] * 2; while(cin >> n) { mem(vis, 0); mem(stk, 0); cout << f[n] << " "; tot = 0; fleury(0); tot += n - 2; for(int i = tot; i > n - 2; i--) cout << stk[i]; cout << endl; } return 0; }