파이썬59 [백준 10844] 쉬운 계단 수 - Python(파이썬) import sys N = int(sys.stdin.readline().strip()) answer = [[0]*10 for _ in range(N+1)] for i in range(1, 10): answer[0][i] = 1 for i in range(1, N+1): for j in range(10): if j == 0: answer[i][j] = answer[i - 1][j + 1] elif j == 9: answer[i][j] = answer[i - 1][j - 1] else: answer[i][j] = answer[i - 1][j - 1] + answer[i - 1][j + 1] print(sum(answer[N-1]) % 1000000000) 2021. 2. 22. [백준 12865] 평범한 배낭 - Python(파이썬) import sys def solution(): for i in range(1, N+1): for j in range(1, K+1): weight = data[i-1][0] value = data[i-1][1] if weight 2021. 2. 22. [백준 7562] 나이트의 이동 - Python(파이썬) import sys def solution(I, start_x, start_y, end_x, end_y): to_go = [(start_x, start_y)] check[start_x][start_y] = 1 ans = 0 while to_go: temp = [] for toX, toY in to_go: if toX == end_x and toY == end_y: return ans for i in range(8): new_x, new_y = toX + dx[i], toY + dy[i] if 0 2021. 2. 22. [백준 1697] 숨바꼭질 - Python(파이썬) import sys def solution(N, K): result = [N] check[N] = 1 ans = 0 while result: temp = [] for re in result: if 0 2021. 2. 22. [백준 1707] 이분 그래프 - Python(파이썬) import sys def solution(): for i in range(1, V+1): if check[i] == 0 and len(data[i]) > 0: keys = [i] check[i] = -1 color = 1 while keys: temp = [] for key in keys: for tp in data[key]: if check[tp] == 0: check[tp] = color temp.append(tp) elif check[tp] != color: return 'NO' color = -color keys = temp return 'YES' K = int(sys.stdin.readline().strip()) for k in range(K): V, E = map(int, sys.stdin... 2021. 2. 22. [백준 2206] 벽 부수고 이동하기 - Python(파이썬) import sys def solution(): my_d = [(0, 0, 1)] check[0][0] = 1 ans = 1 while my_d: temp = [] for x, y, crush in my_d: if x == N-1 and y == M-1: return ans for i in range(4): new_x, new_y = x + dx[i], y + dy[i] if 0 2021. 2. 22. 이전 1 ··· 5 6 7 8 9 10 다음