http://acm.hdu.edu.cn/showproblem.php?pid=1047

大数

View Code
import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner cin=new Scanner (new BufferedInputStream(System.in));
        BigInteger sum,a;
        int n=cin.nextInt();
        for(int i=0;i<n;i++)
        {
            sum=BigInteger.valueOf(0);
            while(cin.hasNext())
            {
                a=cin.nextBigInteger();
                if(a.equals(BigInteger.valueOf(0)))
                    break;
                sum=sum.add(a);
            }
            System.out.println(sum);
            if(i!=n-1)System.out.println();
        }
    }
}