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

Envío 5038

Problema 0x30 - Incrementar un número muy grande

  • Autor: Camilo15
  • Fecha: 2021-10-07 16:20:53 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.12 s 11 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.128 s 11 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.112 s 11 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.119 s 11 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.118 s 11 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.108 s 11 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.106 s 11 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.1 s 11 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.106 s 13 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.114 s 11 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.108 s 11 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.112 s 11 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.118 s 11 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.115 s 11 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.113 s 11 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.105 s 11 KBi
#17
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.121 s 11 KBi
#18
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.131 s 11 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.116 s 11 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.099 s 11 KBi
#21
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.096 s 11 KBi
#22
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.091 s 11 KBi
#23
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.12 s 11 KBi
#24
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.105 s 11 KBi
#25
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.098 s 11 KBi
#26
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.115 s 11 KBi
#27
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.116 s 11 KBi
#28
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.109 s 11 KBi
#29
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.093 s 11 KBi
#30
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.114 s 11 KBi
#31
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.109 s 11 KBi
#32
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.094 s 11 KBi
#33
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.1 s 11 KBi
#34
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
0.116 s 11 KBi
Puntos totales: 0 / 100

Código

import java.util.*;
import java.lang.*;
import java.io.*;

class Ideone {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String number = sc.nextLine();
        String v[] = number.split("");
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < number.length(); i++) {
            list.add(Integer.parseInt(v[i]));
        }
        // int v[] = {7,9,5,9,9};
        System.out.println(sumOne(list));
    }

    public static String sumOne(ArrayList<Integer> list) {

        for (int i = list.size()-1; i >= 0; i--) {
            int value = list.get(i);
            if(value==9 && i>0){
                list.set(i, 0);
            } 
            else{
               list.set(i, value+1);
               return listToString(list);
            }
        }
        
        return listToString(list);
    }

    public static String listToString(ArrayList<Integer> list) {
        String st = "";
        for (int numb : list) {
            st+=numb;
        }
        return st;
    }
}