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 google-code@googlegroups.com.
To unsubscribe from this group, send email to google-code+unsubscr...@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 post to this group, send email to google-code@googlegroups.com.
To unsubscribe from this group, send email to 
google-code+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to