Insect Breeding Time limit:3000/1000ms (java/other) Memory limit:65535/32768k (Java/other) total submission (s): Accepted SUBM Ission (s): Font:times New Roman | Verdana | Georgia Font Size:←→problem Description Scientists have found a special insect in the tropical forest, which has a strong ability to reproduce. Each pair of adult X-per-month Y-pair eggs, each pair of eggs will be two months to grow into adults. Assuming that each adult does not die, the first month only a pair of adults, and eggs into the adult after the first month does not spawn (over X months spawning), asked after the z months, the total number of adults. 0<=x<=20,1<=y<=20,x<=z<=50. Input has multiple sets of data, each set of values x, Y, and Z. Output for each group of data out of the z month after the total number of adults. Sample Input
1 2 8
Sample Output
37
Thinking Analysis: The topic is also a recursive problem, the key is to find the rules of the previous data.
code: #include <iostream> #include <stdio.h> #include <string.h> using namespace std; int main () {& nbsp
__int64 a[60],b[60];
int x,y,z;
int i; while (scanf ("%d%d%d", &x,&y,&z)!=eof) { memset (a,0,
sizeof (a));
memset (b,0,sizeof (b)); for (i=1;i<=x;i++) {a[i]=1,b[i]=0} for (i=x+1;i<=z+1;i++) & nbsp { B[i]=y*a[i-x]; a[i]=a[i-1]+b[i-2]; }
printf ("%i64d\n", a[z+1]);
} return 0; }