Files
python/TangDou/XiTi/1260.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

22 lines
666 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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个月
}