Java 大数相乘.Wrong answer!Problem Description In this problem,y
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/18 13:09:35
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
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
问题主要在这里
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));
}
再问: 还是wrong answer。。
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));
}
再问: 还是wrong answer。。
Java 大数相乘.Wrong answer!Problem Description In this problem,y
Problem Description
杭电acm 2034wrong answer Problem Description参加过上个月月赛的同学一定还记得其中
Problem Description Given a positive integer N,y
改错:1.No one in our class could answer this problem .2.He doe
1.Science will__give us the right answer to this problem in
problem of learn java
what's the answer for this math problem
The answer to this problem involves many factors.
this problem is ______ for you to answer
this maths problem is _____for him yo answer
hdu 1002 A + B Problem II 一直wrong answer,请高手看看哪错了