使用java BigInteger
大数加法 http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1005
import java.math.BigInteger; import java.util.Scanner; public class Nim { public static void main(String[] args) { Scanner cin=new Scanner(System.in); BigInteger a=cin.nextBigInteger(),b=cin.nextBigInteger(); System.out.println(a.add(b)); } }
大数乘法 http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1027
import java.math.BigInteger;
import java.util.Scanner;
public class Nim {
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
BigInteger a=cin.nextBigInteger(),b=cin.nextBigInteger();
System.out.println(a.multiply(b));
}
}