Problem p02990 (python)

Fixed submission:
import numpy as np
import math

n , k = list(map(int, input().split()))
def combi(a,b):
    return  math.factorial(a) // (math.factorial(b) * math.factorial(a-b))
i = 2
mod = 10 ** 9 + 7
for i in range(1, k + 1):
    if n - k + 1 >= i and k - 1 >= i - 1:
        print(int(combi(n - k + 1,i) * combi(k - 1, i - 1) % mod))
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10**9+7
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
mod = 10**9+7
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
N = n - k + 1
combi = [0 for i in range(N+1)]
combi[0] = 1
for i in range(1,N+1):
    combi[i] = (combi[i-1]*(N-i+1)*mod_inv(i,mod)) % mod
fact = [0 for i in range(n+1)]
fact[0] = 1
for i in range(1, n+1):
    fact[i] = (i * fact[i-1]) % mod
for i in range(1, k+1):
    print((combi[i] * fact[k-1] * pow(fact[k-i], -1, mod) * pow(fact[i-1], -1, mod)) % mod)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10**9+7
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
mod = 10**9+7
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
N = n - k + 1
combi = [0 for i in range(N+1)]
combi[0] = 1
for i in range(1,N+1):
    combi[i] = (combi[i-1]*(N-i+1)*mod_inv(i,mod)) % mod
fact = [0 for i in range(n+1)]
fact[0] = 1
for i in range(1, n+1):
    fact[i] = (i * fact[i-1]) % mod
for i in range(1, k+1):
    print((combi[i] * fact[k-1] * pow(fact[k-i], -1, mod) * pow(fact[i-1], -1, mod)) % mod)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math

n , k = list(map(int, input().split()))
kaijou = np.zeros((n + 1,k + 1))
def combi(a,b):
    if kaijou[a][b] == 0:
        kaijou[a][b] = math.factorial(a) / (math.factorial(b) * math.factorial(a-b))
    return kaijou[a][b]
i = 2
mod = 10 ** 9 + 7
for i in range(1, k + 1):
    if n - k + 1 >= i and k - 1 >= i - 1:
        print(int(combi(n - k + 1,i) * combi(k - 1, i - 1) % mod))
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math

n , k = list(map(int, input().split()))
kaijou = np.zeros((n + 1,k + 1))
def combi(a,b):
    if kaijou[a][b] == 0:
        kaijou[a][b] = math.factorial(a) / (math.factorial(b) * math.factorial(a-b))
    return kaijou[a][b]
i = 2
mod = 10 ** 9 + 7
for i in range(1, k + 1):
    if n - k + 1 >= i:
        print(int(combi(n - k + 1,i) * combi(k - 1, i - 1) % mod))
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math

n , k = list(map(int, input().split()))
kaijou = np.zeros((n + 1,k + 1))
def combi(a,b):
    if kaijou[a][b] == 0:
        kaijou[a][b] = math.factorial(a) / (math.factorial(b) * math.factorial(a-b))
    return kaijou[a][b]
i = 2
mod = 10 ** 9 + 7
for i in range(1, k + 1):
    print(int(combi(n - k + 1,i) * combi(k - 1, i - 1) % mod))

Buggy submission (verdict: Runtime Error):
n , k = list(map(int, input().split()))
kaijou = []
kaijou.append(1)
kaijou.append(1)
i = 2
mod = 10 ** 9 + 7
while(i <= n):
    kaijou.append(i * kaijou[i - 1])
    i += 1
for i in range(1, k + 1):
    if i <= n - k + 1:
        b = kaijou[k - 1] / (kaijou[i - 1] * kaijou[k - i])
        a = kaijou[n - k + 1] / ( kaijou[i] * kaijou[n - k + 1 - i])
        print(int((a * b) % mod))
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
n , k = list(map(int, input().split()))
kaijou = []
kaijou.append(1)
kaijou.append(1)
i = 2
mod = 10 ** 9 + 7
while(i <= n):
    kaijou.append(i * kaijou[i - 1])
    i += 1
for i in range(1, k + 1):
    if i <= n - k + 1:
        b = (kaijou[k - 1] / (kaijou[i - 1] * kaijou[k - i]))
        a = (kaijou[n - k + 1] /  (kaijou[i] * kaijou[n - k + 1 - i]))
        print(int(a * b) % mod)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
n , k = list(map(int, input().split()))
kaijou = []
kaijou.append(1)
kaijou.append(1)
i = 2
while(i <= n):
    kaijou.append(i * kaijou[i - 1])
    i += 1
for i in range(1, k + 1):
    if i <= n - k + 1: 
        b = (kaijou[k - 1] / (kaijou[i - 1] * kaijou[k - i]))
        a = (kaijou[n - k + 1] /  (kaijou[i] * kaijou[n - k + 1 - i]))
        print(int(a * b) % 1000000007)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
n , k = list(map(int, input().split()))
kaijou = []
kaijou.append(1)
kaijou.append(1)
i = 2
while(i <= n):
    kaijou.append(i * kaijou[i - 1])
    i += 1
for i in range(1, k+1):
    b = (kaijou[k - 1] / (kaijou[i - 1] * kaijou[k - i]))
    a = (kaijou[n - k + 1] /  (kaijou[i] * kaijou[n - k + 1 - i]))
    print(int(a * b) % 1000000007)

Buggy submission (verdict: Runtime Error):
n , k = list(map(int, input().split()))
kaijou = []
kaijou.append(1)
kaijou.append(1)
i = 2
while(i <= k + 1):
    kaijou.append(i * kaijou[i - 1])
    i += 1
for i in range(1, k + 1):
    a = (kaijou[k - 1] / (kaijou[i - 1] * kaijou[n - i + 1]))
    b = ( kaijou[n - k + 1] /  (kaijou[i] * kaijou[n - k + 1 - i]))
    print(a * b % 1000000007)

Buggy submission (verdict: Runtime Error):
n , k = list(map(int, input().split()))
kaijou = []
kaijou.append(1)
kaijou.append(1)
i = 2
while(i <= k + 1):
    kaijou.append(i * kaijou[i - 1])
    i += 1
for i in range(1, k + 1):
    print(int((kaijou[k - 1] / (kaijou[i - 1] * kaijou[n - i + 1])
    * ( kaijou[n - k + 1] /  (kaijou[i] * kaijou[n - k + 1 - i]))) % 1000000007))

Buggy submission (verdict: Runtime Error):
n , k = list(map(int, input().split()))
kaijou = []
kaijou.append(1)
kaijou.append(1)
i = 2
while(i <= k + 1):
    kaijou.append(i * kaijou[i - 1])
    i += 1
for i in range(1, k + 1):
    print(int((kaijou[k - 1] / (kaijou[i - 1] * kaijou[n - i + 1]) * ( kaijou[n - k + 1] /  (kaijou[i] * kaijou[n - k + 1 - i]))) % 1000000007)

Buggy submission (verdict: Runtime Error):
n , k = list(map(int, input().split()))
kaijou = []
kaijou.append(1)
kaijou.append(1)
i = 2
while(i <= k + 1):
    kaijou.append(i * kaijou[i - 1])
    i += 1
for i in range(1,k + 1):
    print(int((i ** (k - i)) * ( kaijou[n - k + 1] /  (kaijou[i] * kaijou[n - k + 1 - i]))) % 1000000007)

Buggy submission (verdict: Runtime Error):
n , k = list(map(int, input().split()))
kaijou = []
kaijou.append(1)
kaijou.append(1)
i = 2
while(i <= n - k + 1):
    kaijou.append(i * kaijou[i - 1])
    i += 1
for i in range(1,k + 1):
    print(int((i ** (k - i)) * ( kaijou[n - k + 1] /  (kaijou[i] * kaijou[n - k + 1 - i]))) % 1000000007)

Buggy submission (verdict: Runtime Error):
def kaijou(n):
    if (n == 1):
        return 1
    else:
        return n * kaijou(n - 1)

n , k = list(map(int, input().split()))
for i in range(1, k + 1):
    c = kaijou(k + i) / kaijou(i - 1)
    a = kaijou(n - (k + i) + 1)
    b = kaijou(n - k + 1)
    print(c * a / b)