Hi,

I understand that they're using binary search, but I don't know how can it get 
to the solution.
Could someone be very nice and explain the code below, please?
This is from coder "wata":

void solve() {
        long left = 0, right = 1L << 40;
        while (right - left > 1) {
                long n = (left + right) / 2;
                if ((double)(2 * r + 1) * n + 2.0 * n * (n - 1) > 1.5 * t) {
                        right = n;
                } else if ((2 * r + 1) * n + 2 * n * (n - 1) > t) {
                        right = n;
                } else {
                        left = n;
                }
        }
        System.out.println(left);
}

Why those values, why 1.5? Man, I don't understand this code :(

Em sábado, 27 de abril de 2013 05h42min58s UTC-3, Vaibhav Tulsyan  escreveu:
> I was seeing the solutions of the top 10 contestants for the large input of 
> Bull's Eye. They all seem to have used some method involving variables like 
> beginning,end and mid. Can anybody explain to me what method they've applied 
> exactly?
> I just used basic maths to solve it. They seem to have used some better 
> algorithm.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-code/-/nB8pI_xLLzAJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to