标签:style blog class code java tar ext color get int string
//f(1) = 1, f(2) = 1, f(n > 2) = f(n - 1) + f(n - 2)
import java.io.*; import java.util.*; import java.math.*; public class Main { /** * @xqq */ public BigInteger an(int n) { BigInteger c; BigInteger a = BigInteger.valueOf(1); BigInteger b = BigInteger.valueOf(1); for(int i = 1; i < n; i++) { c = a.add(b); a = b; b = c; } return a; } public static void main(String[] args) throws Exception { // 定义并打开输入文件 Scanner cin = new Scanner(System.in); Main e = new Main(); int n; while(cin.hasNext()) { n = cin.nextInt(); System.out.println(e.an(n)); } cin.close(); //关闭输入文件 } }
zoj Fibonacci Numbers ( java , 简单 ,大数),码迷,mamicode.com
zoj Fibonacci Numbers ( java , 简单 ,大数)
标签:style blog class code java tar ext color get int string
原文地址:http://www.cnblogs.com/laiba2004/p/3702909.html