Ive been stumped on this problem for a few days now.
At first I thought I could do this with a bfs or dfs with the only pruning being that I don't do opposite operations in consecutive moves. Hence a 1 can only be followed by a 1,2 or 4 . Hence apart from the first move where there are ...
I incorporated that slick piece of info into my code and now I'm getting 0.006 with 64 mem usage. Then I changed my cout into printf and it further improved to 0.002 !! I guess I can improve that further if I improve my method of finding primes upto 1000 but 0.002 is good enough ...
I've gotten "Accepted" with time of 0.6 s and 8864 of memory.. I thought this would be pretty good. When I open the ranklist, the first page is full of 0.00 guys !! How did you guys do it.
My Algo :
- Find all the primes upto 1000000 - For each number upto 1000000, find it's largest prime divisor ...
Thanks Cho! I got AC. I had made a couple of silly mistakes.
My AC has a time for 0.9 seconds.. I was wondering what yours was because I can see some people have done this problem in 0.02 seconds ! If yours is also low, can you please give me some hints on your algorithm?
I'm getting WA .. I've tested the test cases in another thread and they all work. Can you give you your output for these cases and if mine are all correct can you please suggest some other test cases. Thanks.
And here I am doing it in such a complex way. I got every single valid sequence and then found all the combinations/permutations (never knew the difference ) of them...