코딩 이야기/백준 풀이 (51) 썸네일형 리스트형 백준 4963번: 섬의 개수 파이썬 코드(dfs) import sys one = [-1,1,0,0,1,1,-1,-1] two = [0,0,-1,1,1,-1,1,-1] def dfs(a, b): graph[a][b] = -1 for i in range(8): if 0 백준 1010번: 다리 놓기 파이썬 코드 import math t = int(input()) for i in range(t): n, m = map(int, input().split()) if n < m: temp = m m = n n = temp print(int(math.factorial(n)/(math.factorial(n-m) * math.factorial(m)))) 다른 언어였다면 팩토리얼을 따로 함수로 만들어야하겠지만, 난 그냥 math에 있는 함수 가져다가 풀었다. 푼지 오래된 문제라 푼 과정은 잘 기억나지 않는다. 백준 1012번: 유기농 배추 파이썬 코드(dfs) import sys sys.setrecursionlimit(100000) t = int(sys.stdin.readline()) xx = [-1,1,0,0] yy = [0,0,-1,1] def dfs(a, b): graph[a][b] = -1 for i in range(4): if 0 이전 1 ··· 4 5 6 7 다음