Codves3914 昆虫繁殖 递推 fib变形

来源:互联网 发布:java bigdecimal加法 编辑:程序博客网 时间:2024/04/26 03:21

Codves3914 昆虫繁殖

fib变形。
第n个月的成虫 = 第n-1个月的成虫数 + 第n-2个月的幼虫数。
第n-2个月的幼虫数等于 第(n-2)-x个月的成虫数。
f[n]=f[n1]+yf[n2x]

#include <cstdio>#include <cstring>#include <iostream>#include <cstdlib>using namespace std;typedef long long LL;#define MAXN 1000LL f[MAXN];int main(){    LL x, y, z;    cin >> x >> y >> z;    for(int i = 1; i <= x; ++ i) f[i] = 1;    for(int i = x+1; i <= z+1; ++ i)        f[i] = f[i-1] + y*f[i-2-x];    cout << f[z+1] << endl;    return 0;}
1 0
原创粉丝点击