Java 大数相乘.Wrong answer!Problem Description In this problem,you will be concerned with intimport java.math.*;import java.util.*;public class Main{static BigInteger a,b;public static void main(String[] args){Scanner c=new Scanner(System.in);Sca
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 06:46:39
Java 大数相乘.Wrong answer!Problem Description In this problem,you will be concerned with intimport java.math.*;import java.util.*;public class Main{static BigInteger a,b;public static void main(String[] args){Scanner c=new Scanner(System.in);Sca
Java 大数相乘.Wrong answer!Problem Description In this problem,you will be concerned with int
import java.math.*;
import java.util.*;
public class Main{
static BigInteger a,b;
public static void main(String[] args){
Scanner c=new Scanner(System.in);
Scanner d=new Scanner(System.in);
while(c.hasNext()){
a=c.nextBigInteger();
b=d.nextBigInteger();
System.out.println(a.multiply(b));
}
}
}
Problem Description
In this problem,you will be concerned with integers with very large numbers of digits.You must write code which will repeatedly accept (until end of file) two lines each containing an unsigned integer,and output the product of the two input unsigned integers.The output must not contain any leading zeros.
You can assume that each integer will contain at most 80 digits.The input ends with an end of file.
Sample Input
0342
1298
12
3
Sample Output
443916
36
Java 大数相乘.Wrong answer!Problem Description In this problem,you will be concerned with intimport java.math.*;import java.util.*;public class Main{static BigInteger a,b;public static void main(String[] args){Scanner c=new Scanner(System.in);Sca
问题主要在这里
while(c.hasNext()){
a=c.nextBigInteger();
b=d.nextBigInteger();
System.out.println(a.multiply(b));
}
根据题意,需要换行(accept (until end of file) two lines ),两行
而你的程序是无需换行的,你应该使用scan的nextLine方法,如下
while(c.hasNextLine()){
a=new BigInteger(c.nextLine());
b=new BigInteger(c.nextLine());
System.out.println(a.multiply(b));
}