matthewsamuel95 / ACM-ICPC-Algorithms

Algorithms used in Competitive Programming
2.07k stars 1.26k forks source link

Calculation bug #993

Open glenprivacy opened 5 years ago

glenprivacy commented 5 years ago

mid = (lower + (higher - lower)) / 2; is not working mid will just turn out to be higher / 2 in every loop

glenprivacy commented 5 years ago

Or it should be lower + (higher - lower) / 2 as it seems like the previous editor wanted to avoid overflow for large value calculation