题目链接:蜜蜂路线
初始条件:f(0) = 0, f(1) = 1
递推关系式: f(n) = f(n-1) + f(n-2) ,n>=2
java代码:
import java.math.BigInteger;import java.util.Scanner;public class Main {public static void main(String[] args) {int m,n;Scanner in = new Scanner(System.in);m = in.nextInt();n = in.nextInt();BigInteger a = BigInteger.valueOf(0); // ==>arr[0]BigInteger b = BigInteger.valueOf(1); // ==>arr[1]BigInteger c = BigInteger.valueOf(1); // ==>arr[2]for(int i=2;i<=n-m+1;++i) {c = a.add(b);a = b;b = c;}System.out.println(c);}}