Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread vaibhav agarwal
shuldn't it be f(246+m)%10 last one On Thu, Jun 16, 2011 at 9:04 AM, saurabh singh saurab...@gmail.com wrote: t,m;f(n){return n=2?1:f(n-1)+f(n-2);} main(){scanf(%d,t);while(t--)scanf(%d,m)printf(%d\n,f(m+11)-f(m+1)+f(6+m)%10));} My best attempt with the c code..132 bytes still Now

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread kartik sachan
ACTUALLY FIBBONACCI SERIERS REAPEAT AFTER 60 TERM SO 246%60 WILLBE 6 SO WE ONLY HAVE TO FIND M+6 TERM -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread vaibhav agarwal
got it repetition in cycles of 60 On Thu, Jun 16, 2011 at 12:35 PM, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: shuldn't it be f(246+m)%10 last one On Thu, Jun 16, 2011 at 9:04 AM, saurabh singh saurab...@gmail.comwrote: t,m;f(n){return n=2?1:f(n-1)+f(n-2);}

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread PRAMENDRA RATHi rathi
without DP it will be TLE.. - PRAMENDRA RATHI NIT ALLAHABAD On Thu, Jun 16, 2011 at 9:04 AM, saurabh singh saurab...@gmail.com wrote: t,m;f(n){return n=2?1:f(n-1)+f(n-2);}

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread • » νιρυℓ « •
My AC solution is O(1). On Thu, Jun 16, 2011 at 2:29 PM, PRAMENDRA RATHi rathi prathi...@gmail.comwrote: without DP it will be TLE.. - PRAMENDRA RATHI NIT ALLAHABAD On Thu, Jun 16, 2011 at 9:04 AM, saurabh singh saurab...@gmail.comwrote:

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread saurabh singh
Well dont know...My pure recursive solution in python got AC in 0.07s(93 bytes).No DP involved.And I don't think python is faster than c? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread saurabh singh
Very sorry i did used memoization..Ya not possible with o(2^n) solution...Apologies once again On Thu, Jun 16, 2011 at 3:21 PM, saurabh singh saurab...@gmail.com wrote: Well dont know...My pure recursive solution in python got AC in 0.07s(93 bytes).No DP involved.And I don't think python

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread Piyush/Parrik Ahuja
hint : think it as matrix raised to some power ( then u can compute that in log(n) ) or other way around is to find cycle length . :-) On Thu, Jun 16, 2011 at 3:56 PM, saurabh singh saurab...@gmail.com wrote: Very sorry i did used memoization..Ya not possible with o(2^n)

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread kartik sachan
@vipul what algo u have applied for o(1)?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread • » νιρυℓ « •
Binet's Formula. ( keep shortening :P ) On Thu, Jun 16, 2011 at 5:57 PM, kartik sachan kartik.sac...@gmail.comwrote: @vipul what algo u have applied for o(1)?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread PRAMENDRA RATHi rathi
simple with AWK - PRAMENDRA RATHI NIT ALLAHABAD 2011/6/16 • » νιρυℓ « • vipulmehta.1...@gmail.com Binet's Formula. ( keep shortening :P ) On Thu, Jun 16, 2011 at 5:57 PM, kartik sachan kartik.sac...@gmail.comwrote: @vipul what algo u have applied

Re: [algogeeks] FIBONACCI problem.

2011-06-16 Thread kartik sachan
most simple with bash..using formula 11*f(n+6)+11*f(n+6)%10 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] FIBONACCI problem.

2011-06-15 Thread PRAMENDRA RATHi rathi
problem::: https://www.spoj.pl/problems/FIBSUM/ can anyone suggest idea to reduce my code to 111 byte..its currebt size is about 174 int a[50]={0},t,m; f(int n) { return a[n]=a[n]?a[n]:n=2?1:f(n-1)+f(n-2); } main() { scanf(%d,t); while(t--) { scanf(%d,m) ;

Re: [algogeeks] FIBONACCI problem.

2011-06-15 Thread saurabh singh
t,m;f(n){return n=2?1:f(n-1)+f(n-2);} main(){scanf(%d,t);while(t--)scanf(%d,m)printf(%d\n,f(m+11)-f(m+1)+f(6+m)%10));} My best attempt with the c code..132 bytes still Now gonna try perlIt definitely requires exceptional skills to bring it down to 111 bytes but have this gut feeling

Re: [algogeeks] fibonacci problem

2010-12-21 Thread Nikhil Agarwal
You need to keep generating Fibonacci numbers until you meet the condition.Check for even valued term by using TERM%2==0 and sum up.Fibonacci series grows exponentially so n wont be very high.Take care that it doesn't overflow integer range. On Mon, Dec 20, 2010 at 8:36 PM, Shalini Sah

[algogeeks] fibonacci problem

2010-12-20 Thread Shalini Sah
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... Find the sum of all the even-valued terms in the sequence which do not exceed four million. I'm just a beginner..plz