True, someone asked the same problem on the blog, here's my reply to him,

"True enough, I’ve assumed sqrt() to be O(1) which is comparatively correct
because other operations take a lot of time comparatively. I do not change
precision while running its changed only once, all other operations are
O(1) in the same way you consider a*b, a%b or a/b to be O(1) its not
actually about how the actual thing is implemented but the comparative
effect that it has to the whole function."

I have to disagree with you on the speed though, my solution depends too
much on the underlying implementations of those algorithms but it can out
perform with python 3.3 but not with python 2.7 (g.py includes the given
solution)

[madura@trex-j ~]$ time python2.7 g.py < Downloads/A-large-practice.in >
/dev/null

real    0m1.350s
user    0m1.317s
sys     0m0.030s
[madura@trex-j ~]$ time python3 ~/kdev/bullseye/bullseye.py <
Downloads/A-large-practice.in > /dev/null

real    0m0.738s
user    0m0.727s
sys     0m0.010s



            - Madura A.


On Sat, May 4, 2013 at 6:23 PM, kmwho <iamkm...@gmail.com> wrote:

> Correct me if I am wrong, but
> The answer to your question is given by yourself, it relies on the
> arbitrary precision arithmetic of Decimal module of python, which is doing
> all the work. and infact your solution is slower than the one given in the
> analysis. The given solution works in logarithmic time on t.
> In your solution you use exact sqrt function, which uses babylonian sqrt
> method, which I believe has a similar complexity, but on your desired
> precision (which is set to 10^100)
>
> --
> 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/-/Sa2ZLAa5V2MJ.
> 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