题目地址:http://poj.org/problem?id=1503
BigInteger 就好
import java.util.*;
import java.math.*;
import java.text.*;
import java.io.*;public class Main
{public static void main(String[] args) {Scanner cin = new Scanner(new BufferedInputStream(System.in));BigInteger ans = BigInteger.ZERO;while(cin.hasNext()){String s=cin.nextLine();if(s.equals("0")) break; //不能用s=="0" 这个是比较引用的地址ans=ans.add(new BigInteger(s));}System.out.println(ans);}
}