Problem p02990 (python)

Fixed submission:
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r==0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  if M+1<i:
    red = 0
  else:
    red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r ==0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r ==0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
# 再帰制限に引っかかった場合に外す
# import sys
sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
# 再帰制限に引っかかった場合に外す
# import sys
 sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(3000)
from math import factorial

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = factorial(M+1)//(factorial(i)*factorial(M+1-i))
  blue = factorial(K-1)//(factorial(i-1)*factorial(K-i))
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(3000)
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = cmb(M+1,i)
  blue = cmb(K-1,i-1)
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
from math import factorial
inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  red = factorial(M+1)//(factorial(i)*factorial(M+1-i))
  blue = factorial(K-1)//(factorial(i-1)*factorial(K-i))
  print(red*blue%(10**9+7))

Buggy submission (verdict: Runtime Error):
from math import factorial
inf = input().split()
N = int(inf[0])
K = int(inf[1])
M = N-K
for i in range(1,K+1):
  j = i+1
  red = int(factorial(M+1)/(factorial(i)*factorial(M+1-i)))
  blue = int(factorial(K-1)/(factorial(i-1)*factorial(K-i)))
  print(red*blue%(10**9+7))