POJ 3982 序列(JAVA,简单,大数)

题目

 

//在主类中 main 方法必须是 public static void 的,在 main 中调用非static类时会有警告信息, 
//可以先建立对象,然后通过对象调用方法:
 

 

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

    /**
     * @xqq
     */
    public BigInteger a99(BigInteger a, BigInteger b, BigInteger c) {
        for(int i = 0; i < 97; i++) {
            BigInteger d = a.add(b.add(c));
            a = b;
            b = c;
            c = d;
        }
        return c;
    }
    public static void main(String[] args)    throws Exception {
        // 定义并打开输入文件
        Main e = new Main();
        Scanner cin = new Scanner(System.in);
            
        BigInteger a;
        BigInteger b; 
        BigInteger c;
            
        while(cin.hasNext()) {  //判断是否输入结束
            a = cin.nextBigInteger() ; //大数输入
            b = cin.nextBigInteger() ; //大数输入
            c = cin.nextBigInteger() ; //大数输入    
            System.out.println(e.a99(a, b, c));
        
        }
        
        cin.close();  //关闭输入文件
    }
}
View Code

 

posted @ 2014-05-01 09:57  laiba2004  Views(149)  Comments(0Edit  收藏  举报