## 11000 - Bee

All about problems in Volume 110. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

CMG
New poster
Posts: 37
Joined: Sat Dec 08, 2007 5:01 am
Location: ...
hi again,

your problem is with input n=44.

scott1991
New poster
Posts: 28
Joined: Fri Dec 07, 2007 11:41 pm
cheers again. Ac now

turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
thanks i got AC.

alamgir kabir
New poster
Posts: 37
Joined: Wed Oct 03, 2007 10:42 am

### Re: 11000 - Bee

Please help me. I am getting WA. my code is given bellow. I calculate fibonacci(n) and fibonacci(n +1) then subtract 1 from both of them and print.

Code: Select all

``````#include<stdio.h>

unsigned long a;
unsigned long fib(unsigned long n)
{
unsigned long d, b, c, i;
a = 1;
b = 1;
for(i = 1; i <= n; i ++)
{
c = a;
a += b;
b = c;
}
d = a;
a += b;
if(n == 0)
{
return 2;
}
return d;
}

int main()
{
unsigned long n;
while(scanf("%lu", &n) == 1)
{
if(n == -1)
{
break;
}
printf("%lu %lu\n",fib(n)-1, a - 1);
}
return 0;
}
Thanks;
``````

alamgir kabir
New poster
Posts: 37
Joined: Wed Oct 03, 2007 10:42 am

### Re: 11000 - Bee

I have had a stupid mistake.
for n = 0
my solutaion gave 1 0 but it will be
0 1
Now i got accepted.
Thnx

shondhi
New poster
Posts: 25
Joined: Tue Oct 02, 2012 5:24 pm
Location: Chittagong
Contact:

### Got TLE for Bee (Problem ID: 11000)!!!

Code: Select all

``Got AC``
Last edited by shondhi on Fri Apr 12, 2013 5:52 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: Got TLE for Bee (Problem ID: 11000)!!!

Use DP to precompute the results for N<=100.
Check input and AC output for thousands of problems on uDebug!

shondhi
New poster
Posts: 25
Joined: Tue Oct 02, 2012 5:24 pm
Location: Chittagong
Contact:

### Re: Got TLE for Bee (Problem ID: 11000)!!!

Is there another way to decrease the execution time without DP?

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: Got TLE for Bee (Problem ID: 11000)!!!

Memoization
Check input and AC output for thousands of problems on uDebug!

shondhi
New poster
Posts: 25
Joined: Tue Oct 02, 2012 5:24 pm
Location: Chittagong
Contact:

### Re: Got TLE for Bee (Problem ID: 11000)!!!

Thanks, got ac..

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: Got TLE for Bee (Problem ID: 11000)!!!

Here's some input / output I found useful during testing / debugging.

Code: Select all

``Removed because the input / output was incorrect.``