baru003のブログ

baruの雑記兼備忘録

AOJ 0015

・問題リンク National Budget

・コメント
今回はjavaで。
javaにはBigIntegerというクラスがあるのでそちらの恩恵を←

・ソース

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

public class P0015 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			BigInteger sum = sc.nextBigInteger().add(sc.nextBigInteger());
			if (sum.toString().length() > 80) {
				System.out.println("overflow");
			} else {
				System.out.println(sum);
			}
		}
	}

}