Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.135 s | 15 KBi |
#2 |
Correcto
|
0.136 s | 15 KBi |
#3 |
Correcto
|
0.122 s | 12 KBi |
#4 |
Correcto
|
0.132 s | 13 KBi |
#5 |
Correcto
|
0.142 s | 14 KBi |
#6 |
Correcto
|
0.13 s | 14 KBi |
#7 |
Correcto
|
0.125 s | 18 KBi |
#8 |
Correcto
|
0.133 s | 14 KBi |
#9 |
Correcto
|
0.131 s | 16 KBi |
#10 |
Correcto
|
0.136 s | 25 KBi |
#11 |
Correcto
|
0.15 s | 13 KBi |
#12 |
Correcto
|
0.135 s | 14 KBi |
#13 |
Incorrecto
|
0.123 s | 14 KBi |
#14 |
Incorrecto
|
0.123 s | 12 KBi |
#15 |
Incorrecto
|
0.134 s | 26 KBi |
#16 |
Correcto
|
0.141 s | 14 KBi |
#17 |
Correcto
|
0.127 s | 15 KBi |
#18 |
Correcto
|
0.125 s | 12 KBi |
#19 |
Incorrecto
|
0.127 s | 17 KBi |
#20 |
Incorrecto
|
0.143 s | 14 KBi |
#21 |
Incorrecto
|
0.142 s | 14 KBi |
#22 |
Incorrecto
|
0.141 s | 17 KBi |
#23 |
Correcto
|
0.118 s | 14 KBi |
#24 |
Correcto
|
0.135 s | 13 KBi |
#25 |
Correcto
|
0.137 s | 15 KBi |
#26 |
Correcto
|
0.132 s | 14 KBi |
#27 |
Incorrecto
|
0.151 s | 14 KBi |
#28 |
Incorrecto
|
0.141 s | 14 KBi |
#29 |
Correcto
|
0.192 s | 16 KBi |
#30 |
Incorrecto
|
0.274 s | 19 KBi |
#31 |
Incorrecto
|
0.218 s | 18 KBi |
#32 |
Incorrecto
|
0.193 s | 14 KBi |
#33 |
Incorrecto
|
0.203 s | 15 KBi |
#34 |
Incorrecto
|
0.22 s | 16 KBi |
#35 |
Correcto
|
0.225 s | 17 KBi |
#36 |
Correcto
|
0.212 s | 18 KBi |
#37 |
Correcto
|
0.182 s | 16 KBi |
#38 |
Incorrecto
|
0.181 s | 16 KBi |
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String inputX = sc.nextLine(); StringBuilder X = new StringBuilder(); X.append(inputX); X.reverse(); String inputY = sc.nextLine(); StringBuilder Y = new StringBuilder(); Y.append(inputY); Y.reverse(); int sizeX = inputX.length(); int sizeY= inputY.length(); StringBuilder XY = new StringBuilder(); if (sizeX > sizeY) { XY.append(inputX); } else { XY.append(inputY); } int position = 0; int subintX = 0; int subintY = 0; int sumXY = 0; int sizeXY = XY.length(); do { if (position < sizeX && position < sizeY) { subintX = Integer.parseInt(X.substring(position, position + 1)); subintY = Integer.parseInt(Y.substring(position, position + 1)); if (sumXY > 9) { sumXY = subintX + subintY + 1; } else { sumXY = subintX + subintY; } XY.replace(position, position + 1, Integer.toString(sumXY % 10)); } else if (position < sizeX && sumXY > 9) { sumXY = Integer.parseInt(X.substring(position, position + 1)); sumXY++; XY.replace(position, position + 1, Integer.toString(sumXY % 10)); } else if (position < sizeY && sumXY > 9) { sumXY = Integer.parseInt(Y.substring(position, position + 1)); sumXY++; XY.replace(position, position + 1, Integer.toString(sumXY % 10)); } position++; } while (position < sizeXY); if (sumXY > 9){ XY.append(1); } sc.close(); System.out.println(XY.reverse()); } }