Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.101 s | 16 KBi |
#2 |
Correcto
|
0.099 s | 16 KBi |
#3 |
Correcto
|
0.094 s | 16 KBi |
#4 |
Correcto
|
0.094 s | 17 KBi |
#5 |
Correcto
|
0.097 s | 17 KBi |
#6 |
Correcto
|
0.096 s | 16 KBi |
#7 |
Correcto
|
0.1 s | 16 KBi |
#8 |
Correcto
|
0.091 s | 16 KBi |
#9 |
Correcto
|
0.091 s | 16 KBi |
#10 |
Correcto
|
0.094 s | 17 KBi |
#11 |
Correcto
|
0.095 s | 16 KBi |
#12 |
Correcto
|
0.096 s | 16 KBi |
#13 |
Correcto
|
0.081 s | 16 KBi |
#14 |
Correcto
|
0.089 s | 17 KBi |
#15 |
Correcto
|
0.094 s | 17 KBi |
#16 |
Correcto
|
0.095 s | 16 KBi |
#17 |
Correcto
|
0.095 s | 17 KBi |
#18 |
Correcto
|
0.098 s | 17 KBi |
#19 |
Correcto
|
0.099 s | 16 KBi |
#20 |
Correcto
|
0.092 s | 17 KBi |
#21 |
Correcto
|
0.092 s | 17 KBi |
#22 |
Correcto
|
0.092 s | 16 KBi |
#23 |
Correcto
|
0.094 s | 17 KBi |
#24 |
Correcto
|
0.096 s | 17 KBi |
#25 |
Correcto
|
0.089 s | 15 KBi |
#26 |
Correcto
|
0.1 s | 16 KBi |
#27 |
Correcto
|
0.104 s | 16 KBi |
#28 |
Correcto
|
0.08 s | 16 KBi |
#29 |
Correcto
|
0.098 s | 16 KBi |
#30 |
Correcto
|
0.089 s | 16 KBi |
#31 |
Correcto
|
0.098 s | 17 KBi |
#32 |
Correcto
|
0.094 s | 16 KBi |
#33 |
Correcto
|
0.099 s | 17 KBi |
#34 |
Correcto
|
0.095 s | 16 KBi |
#35 |
Correcto
|
0.095 s | 17 KBi |
#36 |
Correcto
|
0.195 s | 24 KBi |
#37 |
Correcto
|
0.211 s | 21 KBi |
#38 |
Correcto
|
0.234 s | 28 KBi |
#39 |
Correcto
|
0.213 s | 24 KBi |
#40 |
Correcto
|
0.234 s | 22 KBi |
#41 |
Correcto
|
0.203 s | 25 KBi |
#42 |
Correcto
|
0.182 s | 26 KBi |
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String largeNumber = scanner.nextLine(); int numberToAdd = scanner.nextInt(); char[] numberArray = largeNumber.toCharArray(); for(int i=numberArray.length-1; i>=0; i--){ int number = convertCharToInt(numberArray[i]); int sum = number + numberToAdd; if(sum >= 10){ int newNumber = sum - 10; numberToAdd = 1; numberArray[i] = convertIntToChar(newNumber); } else { numberArray[i] = convertIntToChar(sum); numberToAdd = 0; break; } } if(numberToAdd == 1){ System.out.print(1); } for(int i=0; i<numberArray.length; i++){ System.out.print(numberArray[i]); } } private static int convertCharToInt(char c){ switch (c){ case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; default: System.out.println("NOT GOOD"); return -1; } } private static char convertIntToChar(int x){ switch (x){ case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4'; case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9'; default: System.out.println("NOT GOOD"); return 'n'; } } }