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

### Like this:

Like Loading...

*Related*

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.

@Amishera

It seems like u r good at mathematics.

good luck🙂

if N = 3 then Mnew = 4 and Fnew = 3 how can if possible

because in the previous M=2 and F=2

by 2 female bee we can get 2 male and 2 female and

from immortal bee we get 1Male and 1Female bee

thus 3 Male and 3 Female

please solve my question

abdussalam.bd09@gmail.com

@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

brother

male bee যে বাচ্ছা দিচ্ছে শুনে আশ্চর্য লাগল!

@barkat007

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

thannk.🙂

but your critical output for the test case “45” should be 4807526975 . .🙂

input for 45

output is

2971215072 4807526975

Thanks for the solution , however i found a mathematic proof for this here: http://www.algorithmist.com/index.php/UVa_11000

Its a series very close to fibonacci nos.