Thank you Kannapan. I tested with 1.4 and 1.6 and both worked. 1.0 does't
work.
I also tested the code without the first condition, but it's necessary to
make it work.


On Sat, Apr 27, 2013 at 4:42 PM, Kannappan <deshka...@gmail.com> wrote:

> the 1.5 might just be to speed up the process to get the value. even if
> 1.6 was used or 1.55 was used for that matter, you might still get the
> right answer but with varying speeds. thats just my guess. haven't tried it.
>
>
> On Sat, Apr 27, 2013 at 6:04 PM, newbie007 <lescoutinh...@gmail.com>wrote:
>
>> 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.
>>
>>
>>
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to