Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Blue-Kite authored Apr 3, 2022
1 parent 6e78039 commit dcd9eda
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions 김나연/점프.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#1890
#백준 1890번 점프
#https://www.acmicpc.net/problem/1890

def solution(board, n):
dp = [[0] * n for _ in range(n)] # (i, j) 좌표까지 올 수 있는 방법 수
dp[0][0] = 1 #시작점부터 1 초기화

for i in range(n):
for j in range(n):
if i == n-1 and j == n-1: #종료조건
break

go = board[i][j]
if i+go < n:
dp[i+go][j] += dp[i][j]
if j+go < n:
dp[i][j+go] += dp[i][j]

print(dp[n-1][n-1])
n = int(input())
board = []
for i in range(n):
board.append(list(map(int, input().split())))

solution(board, n)

0 comments on commit dcd9eda

Please sign in to comment.