얼렁뚱땅 백준 문제풀이

[백준 문제풀이] 얼렁뚱땅 1010번 다리놓기 문제 풀이

MOSTAR 2022. 3. 28. 14:15

https://www.acmicpc.net/problem/1010
https://www.acmicpc.net/problem/1010

 

 

 

import sys
case = int(sys.stdin.readline())

#: nCm
def factorial(k) :
	fact = 1
	for i in range(1,k+1) :
		fact *= i
	return fact

def combination(n,r) :
	return factorial(n)/(factorial(n-r) * factorial(r))


for i in range(case) :
	n,m = map(int,sys.stdin.readline().split())
	d = [0] * (m+1)


	for j in range(n,m+1) :
		d[j] = d[j-1] + combination(j-1,n-1)

	print(int(d[m]))

음 .. 음 ..

마치 고등학교 확률과 통계를 푼다고 생각하면 금방 풀 거 같다

근데, combination이 뭐였는지도 까먹어버린거 같다 ㅎ

큰일이다 호호