Page 1 of 1
Posted: Tue Mar 31, 2009 2:36 pm
Can someone tell me how to solve this problem with the correct algorithm? I saw many people solve this problem,
but i have no idea with it. Please help me orz...
Posted: Tue Mar 31, 2009 4:59 pm
I solved it with BFS
Posted: Tue Mar 31, 2009 11:42 pm
Hi! Could you explain it clearly? I has a bottleneck in how to check the halting condition...because such as the third test case
5234 -> 1212, should i check 5234 -> 11212 -> 21212 -> 31212 -> ... ?
By the way, Thank for your reply
Posted: Wed Apr 01, 2009 3:17 am
Well, the statements say
The lock always uses least significant 4 digits after addition
So, all possible states are 0000~9999.. I simply did mod 10000 every time moving into other state..
When I meet the already visited state during the search, I stopped the search..
Hope this help..
Posted: Wed Apr 01, 2009 4:00 am
Oh!! I think i make a big mistake... i transform the problem to the coin change one and solve it by DP...
But due to the cyclic property, i can't always find the best solution
I was too fool to make this mistake orz... and thank you very much!!!
By the way, your blog is very usefull and a perfect site
Thank you again !!
Posted: Wed Apr 01, 2009 5:34 am
You mean Felix Halim's site..? It's not mine.. it's Felix Halim's
He also built the great tool for TopCoder if you are interested..