Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.156 s | 20 KBi |
#2 |
Correcto
|
0.165 s | 14 KBi |
#3 |
Correcto
|
0.38 s | 28 KBi |
#4 |
Correcto
|
0.258 s | 16 KBi |
#5 |
Correcto
|
0.2 s | 16 KBi |
#6 |
Correcto
|
0.169 s | 15 KBi |
#7 |
Correcto
|
0.397 s | 27 KBi |
#8 |
Correcto
|
0.184 s | 23 KBi |
#9 |
Correcto
|
0.226 s | 15 KBi |
#10 |
Correcto
|
0.188 s | 17 KBi |
#11 |
Correcto
|
0.194 s | 17 KBi |
#12 |
Correcto
|
0.204 s | 15 KBi |
#13 |
Correcto
|
0.426 s | 24 KBi |
#14 |
Correcto
|
0.367 s | 17 KBi |
#15 |
Correcto
|
0.188 s | 17 KBi |
#16 |
Correcto
|
0.182 s | 16 KBi |
#17 |
Correcto
|
0.175 s | 15 KBi |
#18 |
Correcto
|
0.198 s | 26 KBi |
#19 |
Correcto
|
0.233 s | 15 KBi |
#20 |
Correcto
|
0.182 s | 26 KBi |
#21 |
Correcto
|
0.21 s | 14 KBi |
#22 |
Correcto
|
0.318 s | 16 KBi |
#23 |
Correcto
|
0.166 s | 15 KBi |
#24 |
Correcto
|
0.298 s | 18 KBi |
#25 |
Correcto
|
0.182 s | 24 KBi |
#26 |
Correcto
|
0.33 s | 88 KBi |
#27 |
Correcto
|
0.372 s | 88 KBi |
#28 |
Correcto
|
0.261 s | 16 KBi |
#29 |
Correcto
|
0.484 s | 21 KBi |
#30 |
Correcto
|
0.212 s | 15 KBi |
#31 |
Correcto
|
0.231 s | 29 KBi |
#32 |
Correcto
|
0.268 s | 27 KBi |
#33 |
Correcto
|
0.311 s | 20 KBi |
#34 |
Correcto
|
0.535 s | 40 KBi |
import java.util.*; public class Main { public static void main(String args[]){ Scanner inputData = new Scanner(System.in); String numRowsColumns = inputData.nextLine(); StringBuilder input = new StringBuilder(); input.append(numRowsColumns); String inputReverse= input.reverse().toString(); int pos=0; for(int i =0; i < numRowsColumns.length();i++) { if(i==numRowsColumns.length()-1) { pos = (numRowsColumns.length() - i) -1; }else { if(inputReverse.charAt(i) == "9".charAt(0) && inputReverse.charAt(i+1)!="9".charAt(0)) { pos = (numRowsColumns.length() - i) -1; break; }; } } pos = (pos==0)?1:pos; String part2= numRowsColumns.substring(pos-1); int sw=0; String valor1=""; String valor2=""; String allnine=""; for(int j=part2.length()-1; j >=0; j--) { allnine+="9"; if(part2.charAt(j)=="9".charAt(0)) { sw=1; valor1+="0"; }else { valor2= Integer.toString(Integer.parseInt(String.valueOf(part2.charAt(j)))+1); break; } } numRowsColumns = numRowsColumns.substring(0,pos-1); valor2=(input.toString().equals(allnine))?"1":valor2; System.out.println(((sw==0)?numRowsColumns+part2.substring(0,part2.length()-1)+valor2 + valor1:numRowsColumns + valor2 + valor1)); } }