-
Title Description:
-
Implement an adder so that it can output the value of a+b.
-
Input:
-
The input includes two numbers A and b, where A and B are not more than 1000 bits in number.
-
Output:
-
There may be multiple sets of test data, for each set of data,
The value of the output a+b.
-
Sample input:
-
2 610000000000000000000 10000000000000000000000000000000
-
Sample output:
-
810000000000010000000000000000000
1 ImportJava.util.Scanner;2 3 Public classmain{4 Public Static voidMain (String[]args) {5Scanner in=NewScanner (system.in);6 while(In.hasnext ()) {7String line=in.nextline ();8String[] A=line.split ("");9 Char[]x=a[0].tochararray ();Ten Char[]y=a[1].tochararray (); One intlen1=x.length; A intLen2=y.length; - intLen=len1>len2?Len1:len2; - Char[]result=New Char[Len+1]; the intJ=0; -Len=0; - while(len1>0| | Len2>0){ - CharRe1= ', re2= '; + if(len1<=0&&len2>0) {re1= ' 0 '; re2=y[--len2];} - Else if(len1>0&&len2<=0) {re1=x[--len1];re2= ' 0 ';} + Else if(len1>0&&len2>0) {re1=x[--len1];re2=y[--len2];} A intre=re1+re2-' 0 '-' 0 ' +J; at if(re>=10){ -Result[len++]= (Char) (re-10+ ' 0 '); -J=1; - } - Else{ -Result[len++]= (Char) (re+ ' 0 '); inJ=0; - } to } + if(j==1){ -result[len++]= ' 1 '; the } * $ while(len>0){Panax NotoginsengSystem.out.print (result[--Len]); - } the System.out.println (); + } A } the } + /************************************************************** - problem:1198 $ user:0000h $ Language:java - result:accepted - time:2190 Ms the memory:94364 KB - ****************************************************************/
Topic 1198:a+b