1207: Multiplication time limit for large integers : 1 Sec memory limit: MB
Submissions: 7 Resolution: 2
Submitted State [Discussion Version] [Propositional person:Liyuansong] The title describes the product of two non-negative integers not exceeding 200 bits. The input has two lines, each of which is a non-negative integer of no more than 200 bits, with no extra leading 0. Outputs a row, that is, the result after multiplying. The result can not have redundant leading 0, that is, if the result is 342, then you cannot output to 0342. Sample input
1234567890098765432100
Sample output
1219326311126352690000
Analysis:
Use Java's BigInteger class to solve
Core code:
1 a = Sc.nextbiginteger (); 2 b = Sc.nextbiginteger (); 3 System.out.println (A.NULTIPLT (b));
Java code Implementation (AC):
1 ImportJava.math.BigInteger;2 ImportJava.util.Scanner;3 4 5 Public classmain{6 Public Static voidMain (String args[]) {7Scanner sc =NewScanner (system.in);8 BigInteger A, b;9A =Sc.nextbiginteger ();Tenb =Sc.nextbiginteger (); One System.out.println (a.multiply (b)); A } -}
Suseoj 1207: Multiplication of large integers (Java, multiply by large number)