每头母牛到第四年生小牛,
f[i] = f[i-1] + f[i-3], i > 4
http://acm.hdu.edu.cn/showproblem.php?pid=2018
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
public static void main(String []args){
Scanner cin = new Scanner(System.in);
Integer N = 55,i,n;
BigInteger[] fm = new BigInteger[N],fx = new BigInteger[N];
for(i = 1; i < 5; ++i)
fm[i] = BigInteger.valueOf(i);
for(; i < N; ++i)
fm[i] = fm[i-1].add(fm[i-3]);
该博客探讨了HDU 2018算法题,涉及母牛繁殖的类斐波那契数列问题。通过动态规划(DP)方法解决,重点在于f[i] = f[i-1] + f[i-3]的递推关系,适用于i大于4的情况。
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



