본문 바로가기

카테고리 없음

[백준 15791번] 세진이의 미팅 (Python3)

mod = 1000000007

N,K = map(int,input().split())

def cal(x,n):
  if n == 1:
    return x
  cal2 = cal(x,n//2)
  if n%2:
    return cal2*cal2*x %mod
  else:
    return cal2*cal2 %mod
numer = denom = 1
for i in range(1,K+1):
  numer = numer*(N+1-i) %mod
  denom = denom*(i) %mod
print(numer*cal(denom,mod-2)%mod)

= [백준 11401번] 이항 계수 3 (Python3) (tistory.com)