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/08/15 04:17:40
![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](/uploads/image/z/13513937-41-7.jpg?t=Java+%E5%A4%A7%E6%95%B0%E7%9B%B8%E4%B9%98.Wrong+answer%21Problem+Description+In+this+problem%2Cyou+will+be+concerned+with+intimport+java.math.%2A%3Bimport+java.util.%2A%3Bpublic+class+Main%7Bstatic+BigInteger+a%2Cb%3Bpublic+static+void+main%28String%5B%5D+args%29%7BScanner+c%3Dnew+Scanner%28System.in%29%3BSca)
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));
}