█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 4448

Problema 0x30 - Incrementar un número muy grande

  • Autor: saris123
  • Fecha: 2021-06-26 18:34:59 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.172 s 14 KBi
#2
Correcto
0.153 s 15 KBi
#3
Correcto
0.17 s 14 KBi
#4
Correcto
0.168 s 14 KBi
#5
Correcto
0.128 s 16 KBi
#6
Correcto
0.186 s 14 KBi
#7
Correcto
0.171 s 14 KBi
#8
Correcto
0.127 s 15 KBi
#9
Correcto
0.144 s 14 KBi
#10
Correcto
0.181 s 16 KBi
#11
Correcto
0.133 s 14 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: start 1, end 2, length 1
	at java.base/java.lang.AbstractStringBuilder.checkRangeSIOOBE(AbstractStringBuilder.java:1813)
	at java.base/java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:1077)
	at java.base/java.lang.StringBuilder.substring(StringBuilder.java:85)
	at Main.main(Main.java:14)
0.136 s 14 KBi
#13
Correcto
0.174 s 14 KBi
#14
Correcto
0.176 s 16 KBi
#15
Correcto
0.15 s 14 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: start 2, end 3, length 2
	at java.base/java.lang.AbstractStringBuilder.checkRangeSIOOBE(AbstractStringBuilder.java:1813)
	at java.base/java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:1077)
	at java.base/java.lang.StringBuilder.substring(StringBuilder.java:85)
	at Main.main(Main.java:14)
0.169 s 13 KBi
#17
Correcto
0.125 s 12 KBi
#18
Correcto
0.139 s 14 KBi
#19
Correcto
0.137 s 21 KBi
#20
Correcto
0.161 s 15 KBi
#21
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: start 8, end 9, length 8
	at java.base/java.lang.AbstractStringBuilder.checkRangeSIOOBE(AbstractStringBuilder.java:1813)
	at java.base/java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:1077)
	at java.base/java.lang.StringBuilder.substring(StringBuilder.java:85)
	at Main.main(Main.java:14)
0.18 s 14 KBi
#22
Correcto
0.157 s 16 KBi
#23
Correcto
0.13 s 14 KBi
#24
Correcto
0.171 s 14 KBi
#25
Correcto
0.148 s 22 KBi
#26
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: start 10000, end 10001, length 10000
	at java.base/java.lang.AbstractStringBuilder.checkRangeSIOOBE(AbstractStringBuilder.java:1813)
	at java.base/java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:1077)
	at java.base/java.lang.StringBuilder.substring(StringBuilder.java:85)
	at Main.main(Main.java:14)
0.224 s 17 KBi
#27
Correcto
0.215 s 16 KBi
#28
Correcto
0.199 s 17 KBi
#29
Correcto
0.177 s 16 KBi
#30
Correcto
0.181 s 15 KBi
#31
Correcto
0.212 s 13 KBi
#32
Correcto
0.2 s 14 KBi
#33
Correcto
0.19 s 14 KBi
#34
Correcto
0.184 s 13 KBi
Puntos totales: 89 / 100

Código

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();
		
		int position = 0;
		int subintX = 0;
		do {
			subintX = Integer.parseInt(X.substring(position, position + 1));
			subintX++;
			if  (subintX <= 9) {
					X.replace(position, position + 1, Integer.toString(subintX));
				} else {
					X.replace(position , position + 1, Integer.toString(0));
			}
			position++;
		} while (subintX > 9);

		sc.close();
		System.out.println(X.reverse());
	}
}