UVA – 424 – Integer Inquiry

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) throws 
                            IOException {
        BigInteger sum = BigInteger.ZERO;
        BufferedReader bf = new BufferedReader(new 
                            InputStreamReader(System.in));
        String s = bf.readLine();
        while (!s.equals("0")) {
            sum= sum.add(new BigInteger(s));
            s= bf.readLine();
        }
        System.out.println(sum);
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: