ACM (UVa) : 11000


Bee

Data type:
Long Long Integer or equivalent

Algorithm:

Each year the number of Male bees equals to:
# the number of Male bees of previous year and
# the number of Female bees of previous year

Similarly, each year the number of Female bees equals to:
# the number of Male bees of previous year

Initially,
Mold (number of previous year’s male bees) = 0
Fold (number of previous year’s female bees)= 1

In each year,
Mnew increased by (Mold+Fold)

Fnew increased by Mold
return Mnew and (Fnew+Mnew)

Another Algorithm:

You can make an equation based on the statistics of the number of bees.

If N = 0 then Mnew = 0 and Fnew = 1

if N =1 then Mnew = 1 and Fnew = 1

if N = 2 then Mnew = 2 and Fnew = 2

if N = 3 then Mnew = 4 and Fnew = 3

if N = 4 then Mnew = 7 and Fnew = 5

if N = 5 then Mnew = 12 and Fnew = 8

if N = 6 then Mnew = ??? and Fnew = ??? may be I don’t know

Critical input:
0
10
35
45

Critical output:
0 1
143 232
24157816 39088168
2971215072 512559679

Advertisements

9 thoughts on “ACM (UVa) : 11000

  1. It seems like it is calculating fibonacci numbers.

    number of females: n-th fibonacci numbers
    number of males: (n-1)th fibonacci number+(n-th fibonacci number)-1.

    Got to find an algorithm to calculate fibonacci numbers efficiently.

  2. @barkat007
    i think you missed the line,
    “while the male bees give birth to one male bee and one female bee”
    male bees can give birth

    let me explain another way ,
    When N = 2 then M = 2 and F = 2
    when N = 3, all male bees have been died
    so, M = 0 and F = 1 (because of one special female bee)

    From previous years two male bees we will get two male and two female bees
    so, M = 2 and F = 3

    and from previous years two female bees we will get two male bees
    so, M = 4 and F = 3

  3. @barkat007
    প্রবলেম সলভ করা দিয়ে কথা .. কে বাচ্চা দিলো, সেটা তো আমাদের দেখার বিষয় না .. 😛

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s