Bignumber operation can be avoid, but you should not use unsigned long long anyway.

http://ideone.com/3nlO2d

Above is another accepted solution, the idea is still BFS, but without BigInteger.

Parker

On 2012/12/19 22:14, thefourtheye dIVi wrote:
Hi Parker,

Thanks for the Suggestion... I am new to the Big Integer stuff, so working on it... Moreover, http://www.spoj.com/forum/viewtopic.php?f=3&t=3555&p=19155

This thread has a solution similar to what I have implemented but no one replied in the thread was worried about the Big Integer, so might it be a bug in my implementation which gets me WA?

But 19998 is a very valid input... :(


On Mon, Dec 17, 2012 at 3:40 AM, ZHANG Xiongqi, Parker <[email protected] <mailto:[email protected]>> wrote:

    Hi thefourtheye dIVi,

    Basically your idea is correct and this problem can be solved
    using BFS.

    However, it is not sufficient to use <unsigned long long> to solve
    this problem because the answer to 19998 is
    1111111111111111111111111111111111110 which is much larger than
    the maximum number that could be represented using unsigned long long.

    One more thing to note, you can keep track of all the possible
    remainder and no need to process the remainder that has appeared
    before. The reason for that is left for your exercise. :)

    Here is the accepted code which I adapted from yours.

    http://ideone.com/7ziUxy

    If you have any more questions, fell free to ask.

    Parker


    On 2012/12/16 22:42, thefourtheye dIVi wrote:

        I am trying to solve http://www.spoj.com/problems/ONEZERO/

        I referred so many internet posts about this, and they all
        talk about storing reminders and building a tree. I am running
        a simple BFS, nothing else... But this gets me WA :(

        http://ideone.com/SZDn5T

        Dont know whats wrong with this code. Please help me fix it.
-- You received this message because you are subscribed to the
        Google Groups "Google Code Jam" group.
        To post to this group, send email to
        [email protected]
        <mailto:[email protected]>.
        To unsubscribe from this group, send email to
        [email protected]
        <mailto:google-code%[email protected]>.
        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 post to this group, send email to [email protected]
    <mailto:[email protected]>.
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:google-code%[email protected]>.
    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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to