I've been working on topcoder recently and I'm stumbling on this question that I can not understand . The question is that F (n) = F (1) + F (2) + ... F (n) is the biggest odd separator for a given "n" like F (n) n. There are many trivial solutions for the answer; However, I found this solution very interesting.
int compute (n) {if (n == 0) 0; Long k = (n + 1) / 2; Return k * k + calculation (n / 2); } However, I do not understand how to get a recurring relation from the statement of such a problem. Can anyone help this?
I believe they are trying to use the following facts:
<(2k + 1) = 2k + 1, that is the largest odd separator number of a strange number.Now {1,2, ..., 2m + 1} to {1,3,5,7, ...} and {2,4,6, ... , 2m} and try to apply the above facts.
Comments
Post a Comment