This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
int x, y, z;
int a[55];//成虫数量数组
int b[55];//幼儿数量数组
int main() {
scanf("%d%d%d", &x, &y, &z);
//从1月到x月
for (int i = 1; i <= x; ++i)
a[i] = 1, b[i] = 0; //第一个x月的成虫数量
//从第x+1月开始有了变化,出生了第一个y对卵
for (int i = x + 1; i <= z + 1; ++i) {
b[i] = y * a[i - x]; //在i月的幼虫只与i-z月前的成虫有关
a[i] = a[i - 1] + b[i - 2]; //第i个月的成虫只与i-1的成虫和i-2的幼虫有关。
}
printf("%d\n", a[z + 1]);//过了z个月