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语言代码)浏览:651 |
简单的a+b (C++语言代码)浏览:858 |
求组合数 (C语言代码)浏览:1159 |
C语言训练-大、小写问题 (C语言代码)浏览:732 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:880 |
简单的a+b (C语言代码)浏览:606 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:690 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:607 |
1013题解浏览:560 |
杨辉三角 (C语言代码)浏览:484 |