|
|
вернуться в форумeasy, you just generate the solutions for 0..100 millions and then you just calculate 1 million values with that algorithme... f(n) depends only from f(n-1), there are 9973 different values, so you can find the period. i don't understand. there may be no period you got AC like this? 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. Well Vlad. It also depends on N as far as I see... Right you are. This function doesn't have period shorter then 3000000 :^) hi, is there any way to solve it without precalculation ?? At least it is uknown to authors of this problem :) 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) |
|
|