题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
http://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
动规
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int count = 0;
int[] num = new int[32];
num[1] = 1;
num[2] = 1;
for(int i = 3; i<=n; i++){
num[i] = num[i-1]+num[i-2];
}
System.out.print(num[n]);
}
}
递归也很神奇