Submission details
Task:ModAdd
Sender:Peng Liu
Submission time:2016-09-24 14:18:57 +0300
Language:Java
Status:READY
Result:
Test results
testverdicttime
#10.09 sdetails
#20.18 sdetails
#30.21 sdetails
#40.19 sdetails
#50.17 sdetails
#60.18 sdetails
#70.21 sdetails
#80.20 sdetails
#90.19 sdetails
#100.19 sdetails

Code

// A Sample Java program for beginners with Competitive Programming
import java.util.*;
import java.lang.*;
import java.io.*;

class ModAdd
{
    // This function returns index of element x in arr[]
    static String modAdd(String a, String b)
    {
        String as= Integer.toString(new Integer(a));
        String bs= Integer.toString(new Integer(b));
        int[] aa= new int[as.length()];
        int[] ba= new int[bs.length()];
        for(int i=0;i<as.length();i++){
            aa[i]=as.charAt(as.length()-i-1)-'0';
        }
        for(int i=0;i<bs.length();i++){
            ba[i]=bs.charAt(bs.length()-i-1)-'0';
        }
        int[] res = new int[aa.length>ba.length?aa.length:ba.length];
        for(int i=0;i<res.length;i++){
            if(aa.length>i && ba.length>i){
                res[i]=(aa[i]+ba[i])%10;
            } else if(aa.length>i){
                res[i]=aa[i];
            } else if(ba.length>i){
                res[i]=ba[i];
            }
        }
        String result = "";
        for(int i=res.length-1;i>=0;--i){
            result = result + res[i];
        }
        return result;

    }

    public static void main (String[] args)
    {
        // Note that size of arr[] is considered 100 according to
        // the constraints mentioned in problem statement.

        IO io = new IO();

        //String a = io.next(); // Reads the next string separated by spaces.
        String a = io.next(); // Reads the next int separated by spaces.
        String b = io.next(); // Reads the next int separated by spaces.
        //long c = io.nextLong(); // Reads the next long separated by spaces.
        //double d = io.nextDouble(); // Reads the next double separated by spaces.


        io.println(modAdd(a,b));
        io.close(); // MUST BE CALLED IN THE END, otherwise some of the output may be missing
    }
}

Test details

Test 1

Verdict:

input
3797629225
9766508989

correct output
2453127104

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "3797629225"...

Test 2

Verdict:

input
552139016901047883384892240490...

correct output
552139016901047883384892240490...

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "55213901690...

Test 3

Verdict:

input
860793811134668093345482099582...

correct output
487710306894083216377653715430...

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "86079381113...

Test 4

Verdict:

input
2
870841652294197226626825161089...

correct output
870841652294197226626825161089...

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "87084165229...

Test 5

Verdict:

input
0
404905566051213252279994991040...

correct output
404905566051213252279994991040...

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "40490556605...

Test 6

Verdict:

input
430112167406460960088878635088...

correct output
430112167406460960088878635088...

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "43011216740...

Test 7

Verdict:

input
867016005819001635643395991596...

correct output
999999999999999999999999999999...

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "86701600581...

Test 8

Verdict:

input
120453771521975552204976752778...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "12045377152...

Test 9

Verdict:

input
239979749009277805816504910098...

correct output
239979749009277805816504910098...

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "23997974900...

Test 10

Verdict:

input
990963963634143754324162574923...

correct output
818540385713473048971388312665...

user output
(empty)

Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "99096396363...