Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.05 s | 13 KBi |
#2 |
Correcto
|
0.067 s | 10 KBi |
#3 |
Correcto
|
0.072 s | 28 KBi |
#4 |
Correcto
|
0.087 s | 10 KBi |
#5 |
Correcto
|
0.042 s | 14 KBi |
#6 |
Incorrecto
|
0.09 s | 15 KBi |
#7 |
Incorrecto
|
0.062 s | 14 KBi |
#8 |
Correcto
|
0.063 s | 14 KBi |
#9 |
Incorrecto
|
0.111 s | 11 KBi |
#10 |
Correcto
|
0.1 s | 10 KBi |
#11 |
Correcto
|
0.085 s | 11 KBi |
#12 |
Correcto
|
0.061 s | 14 KBi |
#13 |
Correcto
|
0.052 s | 14 KBi |
#14 |
Correcto
|
0.05 s | 14 KBi |
#15 |
Correcto
|
0.09 s | 12 KBi |
#16 |
Correcto
|
0.112 s | 11 KBi |
#17 |
Correcto
|
0.048 s | 14 KBi |
#18 |
Correcto
|
0.089 s | 12 KBi |
#19 |
Correcto
|
0.05 s | 14 KBi |
#20 |
Correcto
|
0.059 s | 14 KBi |
#21 |
Correcto
|
0.085 s | 10 KBi |
#22 |
Incorrecto
|
0.042 s | 13 KBi |
#23 |
Incorrecto
|
0.056 s | 14 KBi |
#24 |
Correcto
|
0.079 s | 13 KBi |
#25 |
Correcto
|
0.058 s | 14 KBi |
#26 |
Correcto
|
0.061 s | 14 KBi |
#27 |
Correcto
|
0.053 s | 13 KBi |
#28 |
Correcto
|
0.051 s | 13 KBi |
#29 |
Correcto
|
0.047 s | 13 KBi |
#30 |
Correcto
|
0.053 s | 14 KBi |
#31 |
Correcto
|
0.105 s | 11 KBi |
#32 |
Correcto
|
0.054 s | 13 KBi |
#33 |
Correcto
|
0.051 s | 13 KBi |
#34 |
Incorrecto
|
0.07 s | 24 KBi |
#35 |
Correcto
|
0.05 s | 14 KBi |
#36 |
Correcto
|
0.166 s | 12 KBi |
#37 |
Correcto
|
0.152 s | 12 KBi |
#38 |
Correcto
|
0.063 s | 15 KBi |
#39 |
Correcto
|
0.087 s | 11 KBi |
#40 |
Correcto
|
0.112 s | 11 KBi |
#41 |
Correcto
|
0.115 s | 16 KBi |
#42 |
Correcto
|
0.072 s | 14 KBi |
import java.io.*; import java.util.StringTokenizer; class Main { public static void main(String[] args) throws IOException{ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; st = new StringTokenizer(bf.readLine()); StringBuilder sb = new StringBuilder(); sb.append(st.nextToken().toString()); sb.reverse(); st = new StringTokenizer(bf.readLine()); int k = Integer.parseInt(st.nextToken()); int x = 0; int clave = 0; while(x<sb.length()){ int digito = Integer.parseInt(sb.substring(x,x+1)); if(digito+k>9 && k>0){ String valor = Integer.toString(digito+k); sb.replace(x,x+1,valor.substring(1,2)); clave=1; k=0; x++; continue; } if(clave==1){ if(digito<9){ sb.replace(x,x+1,Integer.toString(digito+1)); break; }else{ sb.replace(x,x+1,"0"); } } if(digito==0){ sb.replace(x,x+1,Integer.toString(digito+k)); clave=5; break; } x++; } int p = 0; sb.reverse(); for(int i=0;i<sb.length();i++){ if(sb.substring(i,i+1).equals("0")){ p++; } } if(clave==5){ System.out.print(sb); }else if(p==sb.length()-1 || p==sb.length()){ System.out.print("1"+sb); }else{ System.out.println(sb); } } }