首页 > 代码库 > nyoj 114 某种序列 【java大数】

nyoj 114 某种序列 【java大数】

rt

代码:

import java.util.Scanner;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		BigInteger a, b, c, ans, temp1, temp2;
		while(cin.hasNextBigInteger()){
			a = cin.nextBigInteger();
			b = cin.nextBigInteger();
			c = cin.nextBigInteger();
			ans = c;
			int i = 3;
			while(i <= 99){
				temp1 = a.add(b);
				ans = temp1.add(c);
				a = b;
				b = c;
				c = ans;
				/*System.out.println(a);
				System.out.println(b);
				System.out.println(c);
				System.out.println(temp1);
				System.out.println(temp2);*/
				i++;
			}
			System.out.println(ans);
		}
	}
}        

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=114

nyoj 114 某种序列 【java大数】