| Task: | ModAdd |
| Sender: | leosplan |
| Submission time: | 2016-09-24 16:28:13 +0300 |
| Language: | Java |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.11 s | details |
| #2 | ACCEPTED | 0.18 s | details |
| #3 | TIME LIMIT EXCEEDED | -- | details |
| #4 | RUNTIME ERROR | 0.13 s | details |
| #5 | RUNTIME ERROR | 0.15 s | details |
| #6 | ACCEPTED | 0.17 s | details |
| #7 | TIME LIMIT EXCEEDED | -- | details |
| #8 | TIME LIMIT EXCEEDED | -- | details |
| #9 | ACCEPTED | 0.18 s | details |
| #10 | TIME LIMIT EXCEEDED | -- | details |
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 as, String bs)
{
int al=as.length();
int bl=bs.length();
int length=al>bl?al:bl;
int offset =0;
String result="";
for(offset=0;offset<length;offset++){
if(al>offset && bl>offset){
int c = (as.charAt(al-offset-1)-'0' + bs.charAt(bl-offset-1) -'0')%10;
result = c + result;
} else {
break;
}
}
if(al>offset){
result = as.substring(0,al-offset) + result;
} else if(bl>offset){
result = as.substring(0,bl-offset) + result;
}
while(result.startsWith("0")){
if(result.length()==1){
break;
}
result = result.substring(1);
}
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: ACCEPTED
| input |
|---|
| 3797629225 9766508989 |
| correct output |
|---|
| 2453127104 |
| user output |
|---|
| 2453127104 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 552139016901047883384892240490... |
| correct output |
|---|
| 552139016901047883384892240490... |
| user output |
|---|
| 552139016901047883384892240490... Truncated |
Test 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 860793811134668093345482099582... |
| correct output |
|---|
| 487710306894083216377653715430... |
| user output |
|---|
| (empty) |
Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 2 870841652294197226626825161089... |
| correct output |
|---|
| 870841652294197226626825161089... |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of...
Test 5
Verdict: RUNTIME ERROR
| input |
|---|
| 0 404905566051213252279994991040... |
| correct output |
|---|
| 404905566051213252279994991040... |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of...
Test 6
Verdict: ACCEPTED
| input |
|---|
| 430112167406460960088878635088... |
| correct output |
|---|
| 430112167406460960088878635088... |
| user output |
|---|
| 430112167406460960088878635088... Truncated |
Test 7
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 867016005819001635643395991596... |
| correct output |
|---|
| 999999999999999999999999999999... |
| user output |
|---|
| (empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 120453771521975552204976752778... |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 239979749009277805816504910098... |
| correct output |
|---|
| 239979749009277805816504910098... |
| user output |
|---|
| 239979749009277805816504910098... Truncated |
Test 10
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 990963963634143754324162574923... |
| correct output |
|---|
| 818540385713473048971388312665... |
| user output |
|---|
| (empty) |
