输入只有1行,即整数N。
可能有多组测试数据,对于每组数据, 输出只有1行,即名名吃巧克力的方案数。
4
5
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] record =new int[21]; record[1]=1; record[2]=2; for (int i = 3; i <= n; i++) { record[i]=record[i-1]+record[i-2]; } System.out.println(record[n]); } }