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

Envío 5360

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

  • Autor: Ikerlb
  • Fecha: 2021-11-24 07:48:47 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 10, in <module>
    for i in range(n + 1):
NameError: name 'n' is not defined
0.026 s 4 KBi
#2
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 4 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.029 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.025 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 10, in <module>
    for i in range(n + 1):
NameError: name 'n' is not defined
0.027 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 10, in <module>
    for i in range(n + 1):
NameError: name 'n' is not defined
0.041 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 10, in <module>
    for i in range(n + 1):
NameError: name 'n' is not defined
0.04 s 4 KBi
#8
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.034 s 4 KBi
#9
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.159 s 42 KBi
#10
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.143 s 42 KBi
#11
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.136 s 42 KBi
#12
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.087 s 23 KBi
#13
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.134 s 42 KBi
#14
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.159 s 42 KBi
#15
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 4 KBi
Puntos totales: 0 / 100

Código

MOD = 10 ** 9 + 7
N = int(input())
coins = list(map(int, input().split(" ")))
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])