import java.io.*; /* * 暴力解法,上限是 55,那我们直接开一个长度为 55 的数组把全部结果算出来,然后再根据要求输出第几年。 * */ public class Main { public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); public static StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); public static PrintWriter cout = new PrintWriter(new OutputStreamWriter(System.out)); public static void main(String[] args) throws Exception { int n, i; int[] f = new int[55]; for (i = 0; i < 4; i++) { f[i] = i; } for (i = 4; i < 55; i++) { f[i] = f[i - 1] + f[i - 3]; } int index; while (true) { cin.nextToken(); index = (int) cin.nval; if (index == 0) { break; } else { cout.println(f[index]); } } cout.flush(); } }
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:623 |
C语言程序设计教程(第三版)课后习题9.1 (Java代码)浏览:481 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:568 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:900 |
Wu-求圆的面积 (C++代码)浏览:1994 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:597 |
回文数字 (C语言代码)浏览:2539 |
1017题解浏览:663 |
循环入门练习5 (C语言代码)浏览:908 |
printf基础练习2 (C语言代码)浏览:547 |