import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextInt()) { // 注意 while 处理多个 case int a = in.nextInt(); // 考虑递推公式 //关键理清楚数量关系: 第n-1个月有能生和不能生的兔子 // 搞清楚啦,是斐波那契数列:f(n+1)=f(n)+f(n-1); int [] f =new int [a+3]; f[1]=1; f[2]=1; for(int i=3;i<=a;i++) { f[i]=f[i-1]+f[i-2]; } System.out.println(f[a]); } } }