|
|
back to boardNo subject Posted by sloboz 14 Apr 2004 08:13 easy, you just generate the solutions for 0..100 millions and then you just calculate 1 million values with that algorithme... Easier way f(n) depends only from f(n-1), there are 9973 different values, so you can find the period. Re: Easier way i don't understand. there may be no period you got AC like this? No subject Can be only 9973 different values of f(n) (0 .. 9972). For each of them we will remember, have we already get it or not. Not more than after 9973 steps we will see repeat. Sequence look like this: a b c ... d (e f g ... h) e ... . Part in brackets is the period. I haven't tried to solve it yet. Re: No subject Well Vlad. It also depends on N as far as I see... Re: No subject Right you are. This function doesn't have period shorter then 3000000 :^) Re: No subject Posted by hajime 16 Apr 2004 15:53 hi, is there any way to solve it without precalculation ?? Re: Easier way I mistaken. Re: No subject At least it is uknown to authors of this problem :) I've tryed. No way but precalc-fake :( (-) Re: I've tryed. No way but precalc-fake :( (-) f(n+MOD*k) = A*f(n) + B for any 'n'. Just find A and B in O(MOD) and get the result in O(N/MOD + N%MOD) |
|
|