Skip to content

Instantly share code, notes, and snippets.

@mojaie
Created December 4, 2011 16:16
Show Gist options
  • Save mojaie/1430569 to your computer and use it in GitHub Desktop.
Save mojaie/1430569 to your computer and use it in GitHub Desktop.
AOJ:0015
import java.util.Scanner;
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
for(int i = 0; i < n; i++) {
BigDecimal a = new BigDecimal(scn.next());
BigDecimal b = new BigDecimal(scn.next());
BigDecimal sum = a.add(b);
if (a.toString().length() > 80 || b.toString().length() > 80
|| sum.toString().length() > 80) {
System.out.println("overflow");
} else {
System.out.println(sum);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment