Task: | ModAdd |
Sender: | david.meichel |
Submission time: | 2018-09-22 13:52:05 +0300 |
Language: | Java |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.14 s | details |
#2 | TIME LIMIT EXCEEDED | -- | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
#4 | TIME LIMIT EXCEEDED | -- | details |
#5 | TIME LIMIT EXCEEDED | -- | details |
#6 | TIME LIMIT EXCEEDED | -- | details |
#7 | TIME LIMIT EXCEEDED | -- | details |
#8 | ACCEPTED | 0.38 s | details |
#9 | TIME LIMIT EXCEEDED | -- | details |
#10 | ACCEPTED | 0.91 s | details |
Code
import java.util.*; import java.io.*; public class Task1 { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String line1 = reader.readLine(); String line2 = reader.readLine(); if (line1.length() < line2.length()) { String tmp = line1; line1 = line2; line2 = tmp; } char[] first = line1.toCharArray(); char[] second = line2.toCharArray(); int[] a = new int[first.length]; for (int i = 0; i < first.length ;i++ ) { a[i] = Integer.parseInt(String.valueOf(first[i])); } int[] b = new int[second.length]; for (int i= 0; i< second.length ;i++ ) { b[i] = Integer.parseInt(String.valueOf(second[i])); } // end of for int[] result = new int[first.length]; for (int i = 1; i <= second.length ;i++ ) { int r = a[a.length-i]+b[b.length-i]; if (r >= 10) { r -= 10; } // end of if result[result.length-i] = r; } // end of for for (int i = 1;i <= a.length - b.length ;i++ ) { int r = a[a.length-b.length-i]; result[result.length-b.length-i] = r; } // end of for print_array(result); } public static void print_array(int[] a) { boolean b = true; boolean zeros = false; for (int i = 0;i < a.length ;i ++ ) { if (a[i] != 0 || zeros) { b = false; zeros = true; System.out.print(a[i]); } } if (b) { System.out.print("0"); } // end of if } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3797629225 9766508989 |
correct output |
---|
2453127104 |
user output |
---|
2453127104 |
Test 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
552139016901047883384892240490... |
correct output |
---|
552139016901047883384892240490... |
user output |
---|
(empty) |
Test 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
860793811134668093345482099582... |
correct output |
---|
487710306894083216377653715430... |
user output |
---|
(empty) |
Test 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
2 870841652294197226626825161089... |
correct output |
---|
870841652294197226626825161089... |
user output |
---|
(empty) |
Test 5
Verdict: TIME LIMIT EXCEEDED
input |
---|
0 404905566051213252279994991040... |
correct output |
---|
404905566051213252279994991040... |
user output |
---|
(empty) |
Test 6
Verdict: TIME LIMIT EXCEEDED
input |
---|
430112167406460960088878635088... |
correct output |
---|
430112167406460960088878635088... |
user output |
---|
(empty) |
Test 7
Verdict: TIME LIMIT EXCEEDED
input |
---|
867016005819001635643395991596... |
correct output |
---|
999999999999999999999999999999... |
user output |
---|
(empty) |
Test 8
Verdict: ACCEPTED
input |
---|
120453771521975552204976752778... |
correct output |
---|
0 |
user output |
---|
0 |
Test 9
Verdict: TIME LIMIT EXCEEDED
input |
---|
239979749009277805816504910098... |
correct output |
---|
239979749009277805816504910098... |
user output |
---|
(empty) |
Test 10
Verdict: ACCEPTED
input |
---|
990963963634143754324162574923... |
correct output |
---|
818540385713473048971388312665... |
user output |
---|
818540385713473048971388312665... |