-
11050번: 이항 계수 1
첫째 줄에 \(N\)과 \(K\)가 주어진다. (1 ≤ \(N\) ≤ 10, 0 ≤ \(K\) ≤ \(N\))
www.acmicpc.net
코드
n, k = map(int, input().split(" ")) cache = [[-1 for _ in range(n+1)] for _ in range(n+1)] def choose(times, got): if times == n: return got == k if cache[times][got] != -1: return cache[times][got] cache[times][got] = choose(times+1, got) + choose(times+1, got+1) return cache[times][got] if k > n: print(0) else: print(choose(0, 0))
'알고리즘 > 백준' 카테고리의 다른 글
[백준] 2630번 색종이 만들기 (파이썬) (0) 2022.01.02 [백준] 1010번 다리 놓기 (파이썬) (0) 2022.01.02 [백준] 12865번 평범한 배낭 (파이썬) (0) 2022.01.02 [백준] 1912번 연속합 (파이썬) (0) 2022.01.02 [백준] 9251번 LCS (파이썬) (0) 2022.01.02