, c , , , , . , (0.5X .. 0.5X+0.5) , X - .
, c 2, 2 26 52 , floor(2*log<sub>2</sub>i), i - , . , m , , , .
, , c, aka 128, 181, 256, 363, 512 .. .
. , . , :
: ( )
counters=[];
lowest=[];
highest=[];
for (i=0;i<m;i++) {
x=getNextInteger();
n=Math.floor(2.0*logByBase(c,x));
counters[n]++;
if (counters[n]==1) {
lowest[n]=x;
highest[n]=x;
} else {
if (lowest[n]>x) lowest[n]=x;
if (highest[n]<x) highest[n]=x;
}
}
zeroflag=true;
intervals=[];
currentLow=0;
currentHigh=0;
for (i=0;i<counters.length;i++) {
if (zeroflag) {
if (counters[i]>0) {
currentLow=lowest[i];
zeroflag=false;
}
} else {
if (counters[i]==0) {
currentHigh=highest[i-1];
intervals.push([currentLow,currentHigh]);
zeroflag=true;
}
}
if (!zeroflag) {
currentHigh=highest[counters.length-1];
intervals.push([currentLow,currentHigh]);
}