We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #122: Efficient exponentiation
Project Euler #122: Efficient exponentiation
Sort by
recency
|
13 Discussions
|
Please Login in order to post a comment
What surprised me the most was that it didn't require memoization.
100/- Points C++ Code
Is this a bruteforce problem-solving model? Can I see other's submission? I gave up :(
Was having trouble with the use of brauer chain (wasn't sure brauer chain necessarily contains one of the shortest chains for every , but it satisfies the input contraint here). Implemented some sort of breadth first search with
deque
and got Runtime Error #2.With a bit of tweaking, I found that for certain input range there must be a shortest chain starting with
[1, 2, 4, 8, 16]
, and some smaller range[1, 2, 4, 8]
. This reduces the queue significantly. Then it passed. Smells like cheating.Hope this is not spoiler on contest. I think it is not, but if admins think it is, feel free to delete.
Gotta say the expert who did handpick the test cases must be some kind of evil genius. Thanks. Got me delving bit deeper into this, since you just happened to pick some cases where Donald Knuth's power tree method fails to create the most optimal chain. There are not many numbers below 10000 where this method fails for creating the optimum chain. Well, Knuth tells in his book what are the numbers. Method itself is blazingly fast.
BUT. Can anyone elaborate WHY power tree method fails on these numbers? My understanding on subject is not enough. Tried to think about it and cant see the reason.