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

Envío 5359

Problema 0xcb - Contar maneras de formar una cantidad con monedas

  • Autor: Ikerlb
  • Fecha: 2021-11-24 07:48:23 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.03 s 3 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.024 s 3 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 10, in <module>
    for i in range(n + 1):
NameError: name 'n' is not defined
0.023 s 3 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 10, in <module>
    for i in range(n + 1):
NameError: name 'n' is not defined
0.026 s 3 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.025 s 3 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.027 s 3 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.028 s 3 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.021 s 3 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.02 s 3 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.023 s 3 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.025 s 3 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.016 s 3 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.029 s 6 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.019 s 3 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    coins = list(map(int, input()))
ValueError: invalid literal for int() with base 10: ' '
0.03 s 3 KBi
Puntos totales: 0 / 100

Código

MOD = 10 ** 9 + 7
N = int(input())
coins = list(map(int, input()))
M = int(input())
MOD = 10**9 + 7

dp = [[0]*len(coins) for _ in range(10001)]
for j in range(len(coins)):
    dp[0][j] = 1
for i in range(n + 1):
    for j in range(len(coins)):
        dp[i][j] = dp[i][j - 1]
        if i - coins[j] >= 0:
            dp[i][j] = (dp[i][j] + dp[i - coins[j]][j]) % MOD

for _ in range(M):
    n = int(input())
    print(dp[n][-1])