for (int i = 0; i < idx; i++) { bs.set(i, (i < oneCnt - 1) ? 1 : 0); } 这步直接用bs.set(idx-1,0)可能更好理解