#include #include #include #include int main(void) { int n=90; int k=5; int sites=10; int i, bestever, base, consider, need, avail, site, delay[901]; long t; srand48(time(&t)); while (1) { base=0; for (site=1;site<=sites;site++) { for (i=1;i<=n;i++) { delay[base+i]=0; } base+=n; } bestever=0; for (i=1;i<=6000;i++) { base=0; for (site=1;site<=sites;site++) { avail=n; need=k; consider=1+base; while (avail>0) { if (drand48()<(double)need/avail) { delay[consider]=0; need--; } else { delay[consider]++; if (delay[consider]>bestever) { bestever=delay[consider]; } } consider++; avail--; } base+=n; } } printf("%i\n", bestever); } }