aboutsummaryrefslogtreecommitdiff
path: root/sd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sd.c')
-rw-r--r--sd.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sd.c b/sd.c
index 7d00989..cd8195d 100644
--- a/sd.c
+++ b/sd.c
@@ -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);