diff options
Diffstat (limited to 'sd.c')
-rw-r--r-- | sd.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -59,6 +59,9 @@ int main(int argc, char* argv[]) { assert(system("stty -F /dev/tty -echo") == 0); while (true) { + /* Make sure sum of weights is positive */ + assert(seg[1] > 0); + int x = (long long)rand() * rand() % seg[1]; int res[2]; query(res, x, 0, N-1, 1); |