标签:style blog class code java tar ext color get int string
//BigInteger 和 BigDecimal 是在java.math包中已有的类,前者表示整数,后者表示浮点数
import java.io.*; import java.util.*; import java.math.*; public class Main { /** * @xqq */ public BigInteger an(BigInteger a, BigInteger b, int n) { if(n == 1) { return a; } for(int i = 2; i < n; i++) { BigInteger c = a.add(b); a = b; b = c; } return b; } public static void main(String[] args) throws Exception { // 定义并打开输入文件 Scanner cin = new Scanner(System.in); Main e = new Main(); int t, n; BigInteger a = BigInteger.valueOf(1); BigInteger b = BigInteger.valueOf(2); t = cin.nextInt(); for(int i = 0; i < t; i++) { n = cin.nextInt() ; System.out.println(e.an(a, b, n)); } cin.close(); //关闭输入文件 } }
HDU 1715 大菲波数(JAVA, 简单题,大数),码迷,mamicode.com
标签:style blog class code java tar ext color get int string
原文地址:http://www.cnblogs.com/laiba2004/p/3702591.html