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: ...

Post by CMG »

hi again,

your problem is with input n=44.
scott1991
New poster
Posts: 28
Joined: Fri Dec 07, 2007 11:41 pm

Post by scott1991 »

cheers again. Ac now :D
turcse143
Learning poster
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Post by turcse143 »

:) thanks i got AC.
alamgir kabir
New poster
Posts: 37
Joined: Wed Oct 03, 2007 10:42 am

Re: 11000 - Bee

Post by alamgir kabir »

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

Post by alamgir kabir »

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 :D
shondhi
New poster
Posts: 25
Joined: Tue Oct 02, 2012 5:24 pm
Location: Chittagong
Contact:

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

Post by shondhi »

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)!!!

Post by brianfry713 »

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)!!!

Post by shondhi »

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)!!!

Post by brianfry713 »

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)!!!

Post by shondhi »

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)!!!

Post by uDebug »

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

Code: Select all

Removed because the input / output was incorrect.
Please see https://www.udebug.com/UVa/11000 instead.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
Post Reply

Return to “Volume 110 (11000-11099)”