Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.092 s | 16 KBi |
#2 |
Correcto
|
0.081 s | 16 KBi |
#3 |
Correcto
|
0.101 s | 16 KBi |
#4 |
Correcto
|
0.099 s | 16 KBi |
#5 |
Correcto
|
0.09 s | 16 KBi |
#6 |
Correcto
|
0.095 s | 16 KBi |
#7 |
Correcto
|
0.1 s | 16 KBi |
#8 |
Correcto
|
0.101 s | 16 KBi |
#9 |
Correcto
|
0.1 s | 16 KBi |
#10 |
Correcto
|
0.13 s | 13 KBi |
#11 |
Correcto
|
0.096 s | 16 KBi |
#12 |
Correcto
|
0.087 s | 16 KBi |
#13 |
Correcto
|
0.1 s | 16 KBi |
#14 |
Correcto
|
0.123 s | 13 KBi |
#15 |
Correcto
|
0.094 s | 15 KBi |
#16 |
Correcto
|
0.096 s | 16 KBi |
#17 |
Correcto
|
0.097 s | 16 KBi |
#18 |
Correcto
|
0.09 s | 16 KBi |
#19 |
Correcto
|
0.094 s | 16 KBi |
#20 |
Correcto
|
0.096 s | 16 KBi |
#21 |
Correcto
|
0.092 s | 16 KBi |
#22 |
Correcto
|
0.104 s | 16 KBi |
#23 |
Correcto
|
0.094 s | 16 KBi |
#24 |
Correcto
|
0.099 s | 16 KBi |
#25 |
Correcto
|
0.099 s | 16 KBi |
#26 |
Correcto
|
0.091 s | 16 KBi |
#27 |
Correcto
|
0.108 s | 13 KBi |
#28 |
Correcto
|
0.103 s | 16 KBi |
#29 |
Correcto
|
0.309 s | 31 KBi |
#30 |
Correcto
|
0.282 s | 27 KBi |
#31 |
Correcto
|
0.282 s | 28 KBi |
#32 |
Correcto
|
0.331 s | 28 KBi |
#33 |
Correcto
|
0.278 s | 30 KBi |
#34 |
Correcto
|
0.282 s | 26 KBi |
#35 |
Correcto
|
0.272 s | 26 KBi |
#36 |
Correcto
|
0.262 s | 26 KBi |
#37 |
Correcto
|
0.318 s | 29 KBi |
#38 |
Correcto
|
0.247 s | 25 KBi |
import java.util.*; import java.lang.*; import java.io.*; class Main { public static void main(String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); String number = sc.nextLine(); String v[] = number.split(""); ArrayList<Integer> list = new ArrayList<>(); for (int i = v.length-1; i >=0; i--) { list.add(Integer.parseInt(v[i])); } String number2 = sc.nextLine(); String v2[] = number2.split(""); ArrayList<Integer> list2 = new ArrayList<>(); for (int i = v2.length-1; i >=0; i--) { list2.add(Integer.parseInt(v2[i])); } sumNumbers(list,list2); } public static void sumNumbers(ArrayList<Integer> listOne, ArrayList<Integer> listTwo) { ArrayList<Integer> list = new ArrayList<>(); int maxSize = listOne.size() >= listTwo.size() ? listOne.size() : listTwo.size(); int carry =0; for (int i = 0; i < maxSize; i++) { int val1= i>=listOne.size() ? 0 : listOne.get(i); int val2= i>=listTwo.size() ? 0 : listTwo.get(i); int sum = val1 + val2 + carry; list.add(sum%10); carry=sum/10; } if(carry!=0) list.add(carry); Collections.reverse(list); listToString(list); } public static void listToString(ArrayList<Integer> list) { StringBuilder st = new StringBuilder(); for (int numb : list) { System.out.print(numb); } } }