본문 바로가기
Algorithm/etc

[파이썬] 백준 - 17단계 조합론

by 베짱이28호 2023. 4. 19.

[파이썬] 백준 - 17단계 조합론


베라의 패션 (15439)

N = int(input())
print(N*(N-1))

녹색거탑 (24723)

N = int(input())
print(2**N)

팩토리얼 (10872)

N = int(input())
n = 1
if 0 <= N <= 1 :
print(1)
else :
for i in range(2,N+1):
n *= i
print(n)

이항계수1 (11050)

N,K = map(int,input().split())
a = list(range(N-K+1,N+1))
b = list(range(1,K+1))
x,y = 1,1
for i in a :
x *= i
for j in b :
y *= j
print(int(x/y))

다리놓기 (1010)

T = int(input())
for i in range(T):
N,M = map(int,input().split())
if N<M :
N,M = M,N
a = list(range(N-M+1,N+1))
b = list(range(1,M+1))
x,y = 1,1
for i in a :
x *= i
for j in b :
y *= j
print(int(x/y))

위아래 순서 있어서 오른쪽 포인트 뽑는 조합의 수

댓글