BigInteger Uva
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { BigInteger ans,Zero; Zero = BigInteger.ZERO; ans = BigInteger.ZERO; Scanner cin = new Scanner(System.in); while(cin.hasNextBigInteger()) { BigInteger temp = cin.nextBigInteger(); if(temp.equals(Zero)) break; ans = ans.add(temp); } System.out.println(ans); } }
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { BigInteger a,b; Scanner cin = new Scanner(System.in); while(cin.hasNextBigInteger()) { a = cin.nextBigInteger(); b = cin.nextBigInteger(); System.out.println(a.multiply(b)); } } }
import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { BigInteger a,b,c; String p,q; Scanner cin = new Scanner(System.in); while(cin.hasNext()) { p = cin.next(); String s = cin.next(); char ch = s.charAt(0); q = cin.next(); System.out.println(p+" "+s+" "+q); a = new BigInteger(p); b = new BigInteger(q); if(ch == '+') c = a.add(b); else c = a.multiply(b); if(a.bitLength() > 31) { System.out.println("first number too big"); } if(b.bitLength() > 31) { System.out.println("second number too big"); } if(c.bitLength() > 31) { System.out.println("result too big"); } } } }