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 n = in.nextInt();
            int[] arr = new int[n];
            arr[0] = 1;
            arr[1] = 1;
            int t = 1;
            for (int i = 2; i < n; i++) {
                arr[i] = arr[i - 2] + arr[i - 1];
            }
            System.out.println(arr[n - 1]);
        }
    }
}

看了大佬的解题思路,第一次有意识的去使用动态规划,列举1-6个月的数量,归纳总结就能得出来