====== 다리 놓기 ====== ===== 풀이 ===== * 기초적인 조합론으로 답이 C(M,N)이 되는것을 쉽게 알수 있다. 이항계수 C(x,y)는 math.comb를 쓰면 된다 * 워낙 간단한 문제라서 숏코딩도 한번 건드려봤다. 기존의 파이썬 최고 기록인 78b를 4byte 더 줄여서 최고기록을 74b로 갱신했다. * 기존 * import math for l in[*open(0)][1:]:print(math.comb(*map(int,l.split()[::-1]))) * 갱신 * import math for l in[*open(0)][1:]:print(math.comb(int(l[2:]),int(l[:2]))) ===== 코드 ===== """Solution code for "BOJ 1010. 다리 놓기". - Problem link: https://www.acmicpc.net/problem/1010 - Solution link: http://www.teferi.net/ps/problems/boj/1010 """ import math def main(): T = int(input()) for _ in range(T): N, M = [int(x) for x in input().split()] print(math.comb(M, N)) if __name__ == '__main__': main() {{tag>BOJ ps:problems:boj:실버_5}}