Re: [algogeeks] Re: Needed recursive sol

2011-10-01 Thread Marcelo Amorim Menegali
Using Wladimir's formulas, you have: F(0) + F(1) + F(2) + F(3) + F(4) + F(5) + F(6) + ... + F(3n-2) + F(3n-1) + F(3n) = F(3n+2) - 1 F(0) +(F(1) + F(2))+ F(3) +(F(4) + F(5))+ F(6) + ... +(F(3n-2) + F(3n-1))+ F(3n) = F(3n+2) - 1 F(0) + 2F(3) + 2F(6) + ... + 2F(3n) = F(3n+2) - 1 Since F(0) = 0,

Re: [algogeeks] string problem

2011-09-17 Thread Marcelo Amorim Menegali
I think you're getting TLE because your solution calculate the same stuff over and over again. Look at this part: else{ *ans[s]=find(s+1,len-1);* if(s[0]'3's[1]'7') *ans[s] = ans[s]+find(s+2,len-2);* } Calculating find(s+1,len-1) imply that

Re: [algogeeks] Party Lamps

2011-09-15 Thread Marcelo Amorim Menegali
Notice that changing the order of button presses doesn't change anything. Notice also that pressing a button twice is the same as not pressing it. So, in the end, given N, there are at most 2^4 = 16 final configurations (each button is either pressed once or not). I hope this will help you. --

Re: [algogeeks] Algorithm to determine the largest number of envelopes that can be nested inside one another.

2010-10-18 Thread Marcelo Amorim Menegali
The problem statement doesn't make it clear, but I guess one can rotate the envelopes (i.e. exchange x_i and y_i). I mean, in the example case of {(1,2),(2,13),(5,10),(7,9),(9,1)}, isn't (1,2),(1,9),(5,10) a valid solution (with length 3), instead of the ones shown (with length 2)? On Sat, Oct