Can any1 please tell me what is wrong wid dis solution?
#include <stdio.h>
int main()
{
long long int f[5000],in,last=f[0];
int i;
while((scanf( "%lld" , &in))==1)
{
for(i=0;i<=in;i++)
{
f[0]=0,f[1]=1;
f =f[i-1]+f[i-2];
if(f >last)
{
last=f ;
}
}
printf("The Fibonacci ...
Search found 4 matches
- Sat Aug 18, 2012 5:59 pm
- Forum: Volume 4 (400-499)
- Topic: 495 - Fibonacci Freeze
- Replies: 222
- Views: 59959
- Sat Aug 18, 2012 11:01 am
- Forum: Volume 109 (10900-10999)
- Topic: 10994 - Simple Addition
- Replies: 41
- Views: 21865
10994- Need help
The solution is correct but it exceeds time limit so what can I do about it? Please tell me anyone. Here is my solution:
#include <stdio.h>
int fu(int ab)
{
if(ab%10>0 && ab>0)
{
return ab%10;
}
else
{
return ab/10;
}
}
int S(int a,int b)
{
int ans=0,i;
for(i=a;i<=b;i++)
{
ans+=fu ...
#include <stdio.h>
int fu(int ab)
{
if(ab%10>0 && ab>0)
{
return ab%10;
}
else
{
return ab/10;
}
}
int S(int a,int b)
{
int ans=0,i;
for(i=a;i<=b;i++)
{
ans+=fu ...
- Sat Aug 18, 2012 3:10 am
- Forum: Volume 109 (10900-10999)
- Topic: 10994 - Simple Addition
- Replies: 41
- Views: 21865
Re: #10994- Need help
can u give 1?



- Fri Aug 17, 2012 9:49 pm
- Forum: Volume 109 (10900-10999)
- Topic: 10994 - Simple Addition
- Replies: 41
- Views: 21865
#10994- Need help
The solution is correct but it exceeds time limit so what can I do about it? :( :( Please tell me anyone. Here is my solution:
#include <stdio.h>
int fu(int ab)
{
if(ab%10>0 && ab>0)
{
return ab%10;
}
else
{
return ab/10;
}
}
int S(int a,int b)
{
int ans=0,i;
for(i=a;i<=b;i ...
#include <stdio.h>
int fu(int ab)
{
if(ab%10>0 && ab>0)
{
return ab%10;
}
else
{
return ab/10;
}
}
int S(int a,int b)
{
int ans=0,i;
for(i=a;i<=b;i ...