0 like 0 dislike

    Suppose there is a pair of newborn bunnies in the pasture in the first month, each pair of male and female bunnies grew into a large male and female rabbits after two months later. After three months from the start, each pair of male and female rabbit can give birth to a pair of small bunnies every month. If the rabbits can live forever, how many pair of rabbits in the pasture in the first N month?

(1<=N<=90)(Very IMPORTANT)

Input

3

Output

2

 

Input

5

Output

5

 

Input

88

Output

1100087778366101931

[Exercise] Coding (C) - asked in C
Available when: Unlimited - Due to: Unlimited

edited by | 285 views

69 Answers

0 like 0 dislike
Hidden content!
#include <stdio.h>







long long int rabbit(int n)



{


** * *** * **** * * * long int value1, value2, value3;


* *** * **** * count = 1;


** * * *** * * * ** ** = 0;


** *** * *** * * * *** * = 1;


** **** ** * * * (n == 2)


** ** * ***** * * * * * * *** *** * * * * * 1;


**** ** ****** *** ** ** if (n == 1)


**** *** * ** * * *** * ** * * **** ** * 1;


***** * *** * * * ** *


** * ** * * ***** * * * * *** * ***** ** * (count < n)


* * * ***** * * ***** * * * * * * * * **


** * *** * * *** ** * * *** ** *** ** ** **** * ****** * *** * * * ** = value1 + value2;


** * ***** ******** ***** * ** * ** ** ** * ** ****


** * *** ** *** ** * * ** * * * *** * ***** * *** ** **** ****** = value2;


* ** * *** * * ** * * ** * *** * * * * * ******** ** * ** * = value3;


*** ** ** * **** *** * * * * *** ** ** ** **


** ** **** * * * * ** * *** * * value3;



}



int main()



{


** ** ** *** * * ** num;


** * * * * * * ** ** * *** ** &num);


* * * ** * ***** * * * ** ******* * * rabbit(num));


*** * ** ** ** *** ** * 0;



}
answered by (6 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>







long long int rabbit(int n)



{


*** * * **** * * * ** * * long int value1, value2, value3;


*** * ** * *** * * * count = 1;


* ***** * * ** * = 0;


* *** *** * ** ** * * = 1;


******** * **** * **** (n == 2)


* ** * *** * * * * ** * * * * ** ** * 1;


* * * * ** *** * if (n == 1)


* * * ** *** * * ******* *** ** * * *** 1;


*** * * * *** *** ** * **


* * * * * **** ***** **** * *** * *** * ***** (count < n)


* ** ** *** **** * * * * * *** ** * *** *


* ** ** * * *** ** ** * * **** * * ****** ** * * * * * * = value1 + value2;


***** ** * * * ** ** * * **** *** ** ***** ** ** **** * ** * ** ***


*** * * * **** * * * * *** *** * * * *** * ** *** * * **** * = value2;


* * * * * * * * * * * * ** ** * *** ** *** * * * *** *** * *** ** ** * = value3;


*** ** **** ** *** *** * ** ** * * *** ** *


* ** * ** ** * *** **** ** ** ***** * ** value3;



}



int main()



{


* ** ** ******* ** num;


** ** *** ***** * * **** ** **** * &num);


** **** **** ** * ** ****** * * ** rabbit(num));


***** * * ** * **** *** ** 0;



}
answered by (-298 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



long long int rabbit(int n)

{
*** * ************* long int value1, value2, value3;
** * * ** * count = 1;
* * ****** * *** ** ** = 0;
** *** * ** ** ***** * * = 1;

    if (n == 2)
* * ** **** * * *** ** *** * ** ** * * * * 1;
* ********* ****** * * if (n == 1)
* * * * **** * ** *** ** ** ** * 1;
* ** ** *** ** * ***** *
*** **** ** ** *** **** *** * ***** * * * * * * (count < n)
* ** * ** *** **** * ********** * * *
* * ** ** * * * * ** *** * **** *** *** * * *** *** **** * * * * = value1 + value2;
** * * * **** * *** *** * * * * * * * * * * ** ******* * *****
*** ** ** *** * * * * * **** * * ** ****** * * * ** * = value2;
*** ******* ** ** * * ** * ** * *** * ***** * * * ** * * *** * **** ***** = value3;
* ** ******* * ** * * ** * **** * **
** * ** *** * * *** * * * *** ** value3;

}

int main()

{
* * ** *** * * **** ** num;
* * ***** * * * * * ***** * **** * * * &num);
*** ** * ** * * * * **** *** * * * ** rabbit(num));
* * ** ** ***** 0;

}
answered by (237 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



long long int rabbit(int n)

{
** **** *** * *** ** * long int value1, value2, value3;
* * ** * ** ***** count = 1;
* ** *** * *** ** * *** * ** = 0;
** * * ** ** ** *** * ***** = 1;

    if (n == 2)
**** ** *** *** **** *** * ** * ** * * * * 1;
** *** ** ** ** * ** ** if (n == 1)
* * * * ** ** * ** ** * ** ** * ** * 1;
* ** * ** * * **
* * * ** * * ***** * *** ** * ** ** **** * (count < n)
* * * * * ***** ***** **** * **** ** * * ** *** * *** **
* * ** * * **** ** * * * ** * ********** * * * * ** *** = value1 + value2;
* * * * * * * ** * ***** * * ** **** *** * * ** * ** * **
** * * ** ***** * **** * **** * * * * *** * ** * ** * * * *** = value2;
* *** *** * * ** * ** ** * **** * * ** *** * *** * * * * * * * * = value3;
* ** * * * * * * * **** ** * ** * *
* *** * * * ** * ** *** ** * * * **** * * * * value3;

}

int main()

{
* *** *** * ** * * * * num;
* * * * * * ***** **** *** * ***** *** * &num);
* ** * ** ******* * ** * rabbit(num));
* * ** *** * ** *** * 0;

}
answered by (-215 points)
0 like 0 dislike
Hidden content!
#include * ** ****

#include * * **** ***



int main()

{
******** *** * * ** n, i;


** * **** * ** * *** &n) != EOF)
* * * *** **** *****
** * **** * * *** * *** **** ** ** ** long long int month[n];
*** **** ** *** **** * *** * **** ** * ** = 1, month[1] = 1;


***** * * * **** * *** * *** * ** *** ** = 2; i < n; i++)
***** * * * * * *** * * * ** **** * *
* **** ** ** ** * ** ** *** * ******* ** * * * *** * *** ** * = month[i-1] + month[i-2];
* * * * * *** * ** ***** * * **** * * * *


***** ** * * *** ******** * * * ** ** * * * ** * * ** * * * month[n-1]);
* *** **** * *** ****


* * * * *** **** * * ** 0;

}
answered by (38 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include * ** * * **



int main()

{
***** *** * ** * n, i;


* * **** * ** *** * ** *** * * * &n) != EOF)
* * * * ** * * **
* * * * ** * ** *** * * ** ** month[n];
* ** *** * ** * * * *** * *** * ** * = 1, month[1] = 1;


*** * * ***** * ** *** * ** ****** * * ** = 2; i < n; i++)
**** * ** ** *** ****** * ***** ** * *
* ***** * ** *** * ** * * * *** * ** * **** ** * **** * = month[i-1] + month[i-2];
*** * *** *** ** * **** ** * ** **** * *


***** * ** * * **** ** **** * * ** * ** * ** * *** ** month[n-1]);
* ** ******* ** *


****** ** ** *** ***** 0;

}
answered by (38 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



long long int rabbit(int n)

{
* ** **** ** ** * * long int value1, value2, value3;
* * * * ** * count = 1;
*** ** ************* * = 0;
*** * ** *** ***** *** * * * = 1;

    if (n == 2)
* **** * **** * * *** * ** * ** **** * * * 1;
* * **** ** ** * * *** * * if (n == 1)
** ** * ***** **** * ** * ** ** * * * *** 1;
* ** * ** ** ******
* ** * * **** ** ** * ** * *** * * ** ** * * ** (count < n)
** * ** * ** * ** *** ** * ***** ** *
** * ** ** * ** * ** *** ** ** *** * * * * ** * * * ** * = value1 + value2;
***** * * ** * *** * ****** * ** * * **** * ***** ** * *** * **** ***
*** * * * * ** * ** ** * **** ***** **** ** * ***** * * * ** * = value2;
* * * * ** * * ** * * ** * ** * * * * * ** ** * *** ** * * ** = value3;
* ** ** * * * **** ** ******* *** * * ***
* * *** ** ** * * * **** * * * * * ******* value3;

}

int main()

{
* * * ** * * * *** * * num;
** *** ** **** * *** ** *** ** * **** * * * &num);
* ** ** *** ** ** * *** * * ** *** rabbit(num));
**** ** * *** ** ** ** ** 0;

}
answered by (126 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



int main()

{
* **** ******* ****** * * i, num;
******* * ** * * * * *** * long total = 0, rabbit = 1, pairs = 1;


*** * *** ** ** * ** * * * &num);


* * * *** ** ** * * * * * = 2; i < num; i++)
* ***** * * * * **** **


* *** *** ***** *** *** * * **** * * *** ****** = rabbit + pairs;
* * * * * ** ** ** *** * * * * * * * ** * *** ** = rabbit;
* * * * ** * **** * * * ** * ****** ** ** ** = total;


*** * ** *** * * ** *
** ** ** * * ***** * ******* == 0)
** * * * * *** ** *
** ** * * ** * * ** ***** * * *** ****** ** ** * ***
*** * *** * * * * * else if(num == 1)
* * ** *** ** * ****
* * * *** * *** ** ** * *** * * * * ***** * *** * * ****
** ** * *** ** * ** * else if(num == 2)
* **** ** * * * * * * *
* * ******** * * * ** **** *** ** * * * * * * * * **** * ** ** * * * ** *
* * * * **** * * else{
* *** ** * *** * **** * ** * **** * * * **** *** *** ** * *

    }




* * *** *** * **** * ** 0;

}
answered by (-189 points)
0 like 0 dislike
Hidden content!
#include * * * **

#include ** * **** ****



long long int fib(int );



int main(){


* *** * **** * * * * * * ** N;
** *** *** ** * **** * long int output;
* ** * *** * ** * * * ** ** ** * *** **** &N);
*** * ** ** * ** * ** * ** *****
** * * ******* * * * ** ** * ** ** ** = fib(N);
* ***** * * ** * * * ** *** * ** ** * ** * * * * * * ** output);
**** **** ** * ** * ** *


* * * **** *** ** * *** *** * 0;

}



long long int fib(int ** * *
* * ** * ** ** ** long int last_2nd = 1, last = 1, output;
** * ** *** * * ** * *** i;
* ** **** **** * ** * == 1 || N == 2)
* ** *** *** * * * *** * *** * * **** ** ** ***** 1;
* * *** **** * * * * *
***** ** * ** **** * * = 2; i<N; i++){
** * * **** ***** * * * ** * **** * ** = last_2nd + last;
* ** * *** * *** ** ** * ** * *** = last;
*** **** *** ** ** * ** **** * * *** ** = output;
* ** * ***** * * ** ***
* ** * **** * ** * * * output;

}
answered by (-188 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



long long int rabbit(int n)

{
* * * * * * ** * * * * *** * long int value1, value2, value3;
* * ** * * * * * *** count = 1;
***** * ** * * *** * = 0;
* *** ** * * * *** *** = 1;

    if (n == 2)
*** * * *** * * *** * ** * * ** * * ** 1;
**** * ****** * ** ** if (n == 1)
***** *** * * * * ** ** * * ***** * ** * *** 1;
* ** ** * *** ** **
* * * ***** ** * ** ** *** * ** **** ** * * (count < n)
* **** * * * ** * **** ** ** * *
*** *** * ** * * *** * * * ** ***** ** ** ** ** * ***** *** * ** * = value1 + value2;
*** **** *** * * * ** * * ** *** * * ** * *** * **** * ** * * **** ***
* ** * ** ** * *** * ** ** * ** * * ** * *** * ****** * *** * * = value2;
* *** * * * ***** ** * ** ** * ** * *** * *** * * ** ** **** * = value3;
**** * * * * * ** * * * *** * **
* * * ** *** **** ******* * ** * * * *** * value3;

}

int main()

{
***** ** * ** * * * *** * num;
** * * ** * ** * * * *** ***** *** * ** ** &num);
* ** ** * ** * * * *** * * * *** **** rabbit(num));
* **** ******** * * * 0;

}
answered by (-218 points)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:173.245.54.235
©2016-2020

Related questions

0 like 0 dislike
23 answers
[Exercise] Essay (Open question) - asked Mar 23, 2017 in C
Available when: Unlimited - Due to: Unlimited
| 249 views
0 like 0 dislike
52 answers
[Exercise] Coding (C) - asked Feb 23, 2017 in C
Available when: Unlimited - Due to: Unlimited
| 309 views
10,552 questions
115,681 answers
103,526 comments
3,772 users