BOJ - 20152 - Game Addiction
Updated:
import sys
def swap(A, B):
C = B
B = A
A = C
return A, B
def solution():
H, N = map(int, sys.stdin.readline().split())
if H == N:
print(1)
return
if H > N:
H, N = swap(H, N)
maps = [[0 for _ in range(31)] for _ in range(31)]
maps[H][H] = 1
for i in range(H, N + 1):
maps[H][i] = 1
for i in range(H + 1, N + 1):
for j in range(H + 1, N + 1):
if i > j: continue
else:
maps[i][j] = maps[i - 1][j] + maps[i][j - 1]
print(maps[N][N])
solution()
https://www.acmicpc.net/problem/20152
Leave a comment