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

Envío 3044

Problema 0x30 - Incrementar un número muy grande

  • Autor: EduardoVega
  • Fecha: 2021-02-16 03:04:49 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.008 s 1 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.009 s 1 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 14 KBi
#4
Correcto
0.004 s 1 KBi
#5
Correcto
0.005 s 1 KBi
#6
Correcto
0.004 s 1 KBi
#7
Correcto
0.005 s 16 KBi
#8
Correcto
0.006 s 1 KBi
#9
Correcto
0.007 s 1 KBi
#10
Correcto
0.004 s 1 KBi
#11
Correcto
0.004 s 2 KBi
#12
Correcto
0.004 s 1 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.005 s 1 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 2 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 2 KBi
#17
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 2 KBi
#18
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 2 KBi
#21
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 1 KBi
#22
Correcto
0.003 s 1 KBi
#23
Correcto
0.004 s 16 KBi
#24
Correcto
0.003 s 1 KBi
#25
Correcto
0.005 s 1 KBi
#26
Correcto
0.006 s 1 KBi
#27
Correcto
0.004 s 2 KBi
#28
Correcto
0.005 s 1 KBi
#29
Correcto
0.005 s 16 KBi
#30
Correcto
0.004 s 1 KBi
#31
Correcto
0.004 s 1 KBi
#32
Correcto
0.004 s 1 KBi
#33
Correcto
0.006 s 1 KBi
#34
Correcto
0.004 s 1 KBi
Puntos totales: 65 / 100

Código

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char *num = NULL;
    size_t len = 0;
    ssize_t nread;
    int i;
    int carry = 1;

    nread = getline(&num, &len, stdin);

    for(i = nread - 2; i >= 0 && carry; i--)
    {
        if(num[i] == 57)
            num[i] = 48;
        else
            num[i] += carry--;
    }
    
    if(num[0] != '\n' && carry == 1)
        putchar('1');
    
    for(i = 0; num[i] != '\n'; i++)
        putchar(num[i]);

    free(num);
    return 0;
}