/* Contract a column transition one lattice square at a time. The states use exactly m-1 ternary digits, independently of the height sign. */ typedef unsigned long long U64; typedef __SIZE_TYPE__ Size; extern int printf(const char *, ...); extern int atoi(const char *); extern void *calloc(Size, Size); extern void *malloc(Size); extern void free(void *); extern void exit(int); static void add(U64 *to,U64 v) { U64 before=*to; *to+=v; if(*to16||maxn<2||degree<2||degree>28)return 1; int stride=degree+1,powers[17]; powers[0]=1; for(int i=1;i>1)?1:-1,prev=(ch&1)?1:-1; int x=(digit==0?1:-1), lnext=(digit==2?-1:1); int cost=(r==-1 && prev==1 && x==-1); na[in]=0; for(int flip=0;flip<=(x==r);flip++) { int outdigit=flip?2:(x==r?0:1); int rnext=flip?-r:r; int outch=2*(rnext==lnext)+(x==lnext); arcs[in][na[in]++]=(Arc){4*outdigit+outch,cost}; } } printf("height %d ternary states %d\n",m,states); for(int n=2;n<=maxn;n++) { U64 sums[32]={0}; for(int s=0;s