Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.095 s | 16 KBi |
#2 |
Incorrecto
|
0.084 s | 16 KBi |
#3 |
Incorrecto
|
0.1 s | 16 KBi |
#4 |
Incorrecto
|
0.108 s | 16 KBi |
#5 |
Correcto
|
0.102 s | 17 KBi |
#6 |
Correcto
|
0.1 s | 16 KBi |
#7 |
Correcto
|
0.094 s | 16 KBi |
#8 |
Correcto
|
0.088 s | 16 KBi |
#9 |
Correcto
|
0.1 s | 16 KBi |
#10 |
Correcto
|
0.118 s | 15 KBi |
#11 |
Correcto
|
0.103 s | 16 KBi |
#12 |
Correcto
|
0.095 s | 15 KBi |
#13 |
Incorrecto
|
0.103 s | 16 KBi |
#14 |
Incorrecto
|
0.083 s | 16 KBi |
#15 |
Incorrecto
|
0.104 s | 16 KBi |
#16 |
Incorrecto
|
0.099 s | 16 KBi |
#17 |
Incorrecto
|
0.089 s | 16 KBi |
#18 |
Incorrecto
|
0.09 s | 16 KBi |
#19 |
Incorrecto
|
0.117 s | 15 KBi |
#20 |
Incorrecto
|
0.098 s | 16 KBi |
#21 |
Incorrecto
|
0.094 s | 16 KBi |
#22 |
Incorrecto
|
0.094 s | 16 KBi |
#23 |
Incorrecto
|
0.099 s | 16 KBi |
#24 |
Incorrecto
|
0.096 s | 16 KBi |
#25 |
Incorrecto
|
0.105 s | 16 KBi |
#26 |
Incorrecto
|
0.1 s | 15 KBi |
#27 |
Incorrecto
|
0.098 s | 16 KBi |
#28 |
Incorrecto
|
0.104 s | 16 KBi |
#29 |
Incorrecto
|
0.163 s | 19 KBi |
#30 |
Incorrecto
|
0.192 s | 23 KBi |
#31 |
Incorrecto
|
0.183 s | 21 KBi |
#32 |
Incorrecto
|
0.192 s | 20 KBi |
#33 |
Incorrecto
|
0.184 s | 20 KBi |
#34 |
Incorrecto
|
0.222 s | 20 KBi |
#35 |
Correcto
|
0.197 s | 21 KBi |
#36 |
Correcto
|
0.218 s | 20 KBi |
#37 |
Incorrecto
|
0.152 s | 19 KBi |
#38 |
Incorrecto
|
0.146 s | 20 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])); } System.out.println(sumNumbers(list,list2)); } public static String sumNumbers(ArrayList<Integer> listOne, ArrayList<Integer> listTwo) { ArrayList<Integer> list = new ArrayList<>(); // int minSize = (listOne.size() <= (listTwo.size() ) ? listOne.size() : listTwo.size(); int carry =0; for (int i = 0; i < listOne.size() && i < listTwo.size(); i++) { int val1= listOne.get(i)==null ? 0 : listOne.get(i); int val2= listTwo.get(i)==null ? 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); return listToString(list); } public static String listToString(ArrayList<Integer> list) { StringBuilder st = new StringBuilder(); for (int numb : list) { st.append(numb); } return st.toString(); } }